C# Code
Char.GetNumericValue Method Converts a specified numeric Unicode character to a double-precision floating-point number.
int result = (int)Char.GetNumericValue('1'); // Output // result = 1
FYI,
Note: Below statement treats the argument as char and returns its ascii value. It is returning the ASCII value of character 1.
int result1 = Convert.ToInt32('1'); // Output // result = 49
Note: Below statement treats the argument as string and converts the value into Int.
int result1 = Convert.ToInt32("1"); // Output // result = 1
No comments:
Post a Comment