ASCII values

  • Thread starter Thread starter Dan Colbert
  • Start date Start date
D

Dan Colbert

Simple but potentially dumb question:

How can I get the ASCII numeric value for a character in C#? In FoxPro, the
function ASC("A") returns a 65 (int). Is there a similar function in C#?

Thanks in advance.

Dan Colbert
Senior Process Engineer
JDA eHealth Systems, Inc.
 
Dan Colbert said:
Simple but potentially dumb question:

How can I get the ASCII numeric value for a character in C#? In FoxPro, the
function ASC("A") returns a 65 (int). Is there a similar function in C#?

Just cast the character to an int, and it will give you the Unicode
value. (You don't actually need the cast unless you're distinguishing
between overloads.) The Unicode value of any ASCII character is the
same as its ASCII value.

For instance:

int i = 'a'; // i is now 65.
 
Thanks!

Jon Skeet said:
C#?

Just cast the character to an int, and it will give you the Unicode
value. (You don't actually need the cast unless you're distinguishing
between overloads.) The Unicode value of any ASCII character is the
same as its ASCII value.

For instance:

int i = 'a'; // i is now 65.
 
Back
Top