ascii

G

Guest

Hi all,
I want to take ascii code of one character.I tried with Encoding but it
wants Byte array.But I want just one character.
Thanks...
 
W

Wessel Troost

I want to take ascii code of one character.I tried with Encoding but it
wants Byte array.But I want just one character.

String unicodeString = "A";
Byte[] encodedBytes = Encoding.ASCII.GetBytes(unicodeString);
Console.WriteLine( "ASCII valueof {0} is {1}.",
unicodeString, encodedBytes[0] );

Greetings,
Wessel
 
R

realfun

do you mean convert a letter expressed by <char> to a <byte>?

pls use an example to explain your question
 
P

Paul E Collins

Wessel Troost said:
I want to take ascii code of one character.

string s = "some string";
char c = s[0]; // first character in s
int i = (int) c; // the value of c

C# uses Unicode, so this even works for non-ASCII characters (values
above 127).

P.
 

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

Top