+ 1
Console.WriteLine (Convert.ToChar(2));
The output is wired, could someone help me, please
5 Answers
+ 3
The Convert.ToChar method converts the ASCII code given as argument to char and not the argument itself. For example, if you wanted to convert "A" to char, you will write Convert.ToChar(65), as the ASCII code of A is 65. In the same way, if you wanted to convert 2 to char, you will write Convert.ToChar(49) as the ASCII value for '2' is 49. Here is a list of all the ASCII values
https://theasciicode.com.ar/
+ 1
What have you done so far?
Show your code progress.
+ 1
ASCII character 2 is the non-printable character STX (start of text) and the equivalent of CTRL-B.
+ 1
David Yan no. The ASCII values only apply for chars. The char you use in any programming language, are actually these values inside. The other Convert.To don't use ASCII values. You can easily convert a string to int by Convert.ToInt32("1234").
0
XXX ,do all Convert.To method converts the ASCII code?