0

I am facing some weird issue, appreciate any help on this.

I am using VS 2019 and .Net Core 2.2. In VS created new web api and if I pass integer value 5 in the controller the id value shows as hex ( id = 0x00000005) also I declared integer as below and shows the value as s = 0x00000009. I don't have any code or settings to change hex value. Tested with new web api project with endpoint https://localhost:44358/api/values/5. Decimal, string type works as expected. Please help me here.

    // GET api/values/5
    [HttpGet("{id}")]
    public ActionResult<string> Get(int id)
    {
        int s = 9;
        return "value";
    }

Appreciate any help.

  • 1
    What's the issue? You don't want to display the values as hex? –  Jan 20 '20 at 18:10
  • [HttpGet("{id:int}")] – LinkedListT Jan 20 '20 at 18:13
  • Yes I don't want in hex , I want to display integer value as declared integer data type. I tried with [HttpGet("{id:int}")] but no luck. Both id and s variable value display in hex. – Srilakshmidaran Salla Jan 20 '20 at 18:24
  • Showing as hex in your IDE has *nothing* to do with your code. See the marked duplicate. –  Jan 20 '20 at 18:25
  • The issue is when I assign this int value to database param value, since hex value assigned DB proc is failing. I declared int data type not sure why and where IDE is converting as hex value. – Srilakshmidaran Salla Jan 20 '20 at 18:32
  • 1
    `5` and `0x00000005` are the *same* value, being displayed to you differently. It has nothing to do with your database or how your code behaves. It's strictly how information is presented in the IDE. There is no conversion. Again, see the marked duplicate to tell your IDE to stop displaying as hex. –  Jan 20 '20 at 18:36

0 Answers0