Asc equivalent?

  • Thread starter Thread starter Peter Z
  • Start date Start date
P

Peter Z

Hello folks,

Does anyone know the equivalent VB Asc function for C#?

Or ways around it?


Thanks in advance
Pete
 
Peter Z said:
Does anyone know the equivalent VB Asc function for C#?

Or ways around it?

Could you say *exactly* what you want to do? Note that the value of any
char is its unicode value - and if the character is an ASCII character,
that will be exactly the ASCII value.

If you want to know the value of any character in the system's default
code page, you should look at using Encoding.Default.
 
Marvellous effort that!


NULL said:
Hello folks,

Does anyone know the equivalent VB Asc function for C#?

Or ways around it?

try this

int nASCII = (int)'A'; //should give 65 or 91 or something like
//that...?
int nASCII2 = (int)myCharVariable;
int nASCII3 = (int)myString[1]; //second char in string
 
NULL said:
What do you mean?

It is simple as 1-2-4 (sorry, 1-2-3 :) )
just like in C, C++ (etc.) a char is a datatype of 1 byte

Um, no. char is a datatype of *2* bytes...
 
It's a way of saying thankyou!

:D
np (sorry, a bit too much hours wihtout sleep I guess. :S sorry)
NULL said:
Marvellous effort that!

What do you mean?

It is simple as 1-2-4 (sorry, 1-2-3 :) )
just like in C, C++ (etc.) a char is a datatype of 1 byte, that can be
converted to any other (native) datatype that is larger (int, short,
long, byte, etc...) by just casting it...
You can also try this:

int nASCII = Convert.ToInt32 ('A');
long lASCII = Convert.ToInt64 ('B');
short sASCII = Convert.ToInt16 ('C'); //short==16 bits? (I though so)

--
NULL
"NULL" <Thomas-dot-Delrue-at-Tiscali-dot-Be> wrote in message
On Tue, 2 Sep 2003 18:48:39 +0800, "Peter Z"

Hello folks,

Does anyone know the equivalent VB Asc function for C#?

Or ways around it?

try this

int nASCII = (int)'A'; //should give 65 or 91 or something like
//that...?
int nASCII2 = (int)myCharVariable;
int nASCII3 = (int)myString[1]; //second char in string
 
Back
Top