I have a string varaible str
. This variable has a value "26"
. Can I convert it into hex that results 0x26 not 0x1A.
Means str="26"
int iConvert=**SomeConvertionFunction(str)**
should result into iConvert=0x26
I have a string varaible str
. This variable has a value "26"
. Can I convert it into hex that results 0x26 not 0x1A.
Means str="26"
int iConvert=**SomeConvertionFunction(str)**
should result into iConvert=0x26
int hex = int.Parse("26", NumberStyles.HexNumber);
hex value will be 38
which is the decimal representation of hex number 0x26.
If I understand your question basically you want to store the Hex value of the string in a int?
having the value 26 or 0x1A is the same.
To convert the int to a string use int.ToString('X');
And please not that 26 in base 10 in equal to 0x1A in base 16.