How do you find the ASCII value of a character?
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());
}
}
joy.simpsonPosted Jan 18, 2004, 11:45 PM
Tanvir HudaPosted Jan 18, 2004, 7:38 PM
Tanvir HudaPosted Jan 18, 2004, 7:20 PM
joy.simpsonPosted Jan 18, 2004, 4:15 PM
jcity444Posted Jan 18, 2004, 1:54 PM