C # supports hexadecimal literals :
int i = 0xff;
However, they have the same numeric values ββas decimal literals - you are limited to the type you use. There is no special type of Hexa .
If you have an integer and want to display it in a hexadecimal base, you can use the x format ( example ):
int i = 255; Console.Write(i.ToString("x"));
Please note that the entry i = 0xff or i = 255 exactly the same - the value is resolved by the compiler, and you get the same compiled code.
Finally, if you have strings with hexadecimal numbers, you can convert them to integers, sum them up and reformat them ( example ):
string hexValue = "af"; int i = Convert.ToInt32(hexValue, 16);
source share