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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top