I am using the below code
int.Parse("376")
the result is coming as
int.Parse("376") = 0x00000178 int
and i tried to do as
Convert.Toint32("376")
also then the result is same
please help me how to convert string to number?
It is working fine. 0x00000178
is the hexadecimal representation of 376
.
Your Hex button is enabled in Visual Studio.
0x00000178
is the hexadecimal representation for 376
, so using int.Parse
or Convert.ToInt32
is OK.
However, I suggest to use the int.TryParse()
method:
int i;
if (int.TryParse(yourString, out i))
{
// the string is converted successfully to an int, now you can find the int value in the variable 'i'
}
else
{
// Can't convert to an int: the string contains probably some characters that aren't digits
}
It is working fine. 0x178 is hex based for 376 in decimal.
User contributions licensed under CC BY-SA 3.0