-1

How to convert char to ASCII and display in textbox in C#?

For Eg :

i have char a and i want to convert this to ASCII-code 95 and display it in textbox.

noted : tools = visual Studio express edition 2010

hoddi
  • 1
  • 1
  • 4
  • 2
    Hey, you should read [Ask], the [FAQ] and take the [Tour]. – Ňɏssa Pøngjǣrdenlarp Oct 09 '16 at 14:18
  • okay. thanks for advise – hoddi Oct 09 '16 at 14:23
  • 1
    You can't in general convert a `char` value to an ASCII value, because there are only 128 ASCII values, but tens of thousands of legal `char` values. See the marked duplicate for information about dealing with the subset that _is_ possible to convert. – Peter Duniho Oct 09 '16 at 18:45
  • When you say "ASCII" but don't mean the ASCII character set or its one encoding, people rightly misunderstand. The generic term for "ASCII-code" is "character code." – Tom Blodget Oct 10 '16 at 22:11

3 Answers3

1

Try

int AsciCode = (int)'c';
string AsciStr = AsciCode.ToString();

hope it helps

Shadi Zidan
  • 154
  • 5
0

You can do something like this;

string value = "a";

// Convery your string to ascii.
byte[] asciiBytes = Encoding.ASCII.GetBytes(value);

Hope it helps.

sTg
  • 4,313
  • 16
  • 68
  • 115
0

Try This One

Char chr = 'a';
int Ascii = chr;
TextBox1.Text(Ascii.ToString());