converting int to hex int

F

farseer

every example i found shows how to convert an into to a hex STRING.

But what if i have an API that expects and int or byte parameter, but
that parameter is expected to be a hex value?

for instance, i need to convert
int zeroVK_D = 47;
to
int zeroVK_H = 0x2f;

i would like to convert the first (decimal) to the second (hex). they
both represent the same thing, but i need to assign the hex to an int
to pass to an API. How can i do this type of conversion?
 
J

Jon Skeet [C# MVP]

farseer said:
every example i found shows how to convert an into to a hex STRING.

But what if i have an API that expects and int or byte parameter, but
that parameter is expected to be a hex value?

There's no such thing as a "hex value" or a "decimal value" as far as
an int is concerned - it's just a number.
for instance, i need to convert
int zeroVK_D = 47;
to
int zeroVK_H = 0x2f;

i would like to convert the first (decimal) to the second (hex). they
both represent the same thing, but i need to assign the hex to an int
to pass to an API. How can i do this type of conversion?

There is no conversion required. As you say, they both represent the
same thing - nothing can tell the difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top