Get Ascii value of a character

  • Thread starter Thread starter Sammut
  • Start date Start date
S

Sammut

Hi
I am using the following

Text = Convert.ToChar(67).ToString() & this will give a "C"

How can I do the opposite that is pass a "C" and an integer value is returned.

Thanks

Ivan Sammut
 
Sammut said:
I am using the following

Text = Convert.ToChar(67).ToString() & this will give a "C"

How can I do the opposite that is pass a "C" and an integer value is returned.

The above is pretty unnecessary, to be honest. You can get away without
Convert - just cast:

char c = (char)67;
string s = c.toString();

and the other way round:

string s = "C";
char c = s[0]; // First character in s
int i = c; // i=67 now
 
Back
Top