5
Answers

How do you find the ASCII value of a character?

joy.simpson

joy.simpson

20y
4.1k
1
I got this much to work. It will print each character in the string with the ASCII value next to it. But how can I change it so the num variable is 65 less than the ASCII value so that A = 1, B = 2, etc? And how can I assign the ASCII value to the num variable? num = int(c) doesn't seem to work. static void Main(string[] args) { string mystring = "hello"; int num; mystring = mystring.ToUpper(); foreach(char c in mystring) { Console.Write("{0} - ",c); //num = int(c) - 65; //doesn't work Console.WriteLine(((int)c).ToString()); } }
Answers (5)