0

I have an ASCII value stored as an int and I want ASCII convert to character.

private void button2_Click(object sender, EventArgs e)
{
    String text3 = textBox1.Text;
    String text4 = "";
    byte[] array = Encoding.ASCII.GetBytes(text3);
    foreach (char c in array)
    {
        int ascii = (int)c;
        ascii = ((((ascii / 37 + 657) / 12) - 582) / 11);
        text4 += ascii + "-";
    }

    textBox3.Text = text4;
}
J. Steen
  • 15,470
  • 15
  • 56
  • 63
Gypsy Kanaruk
  • 1
  • 1
  • 1
  • 1
  • Try this post please http://stackoverflow.com/questions/4648781/how-to-get-character-for-a-given-ascii-value – hatem87 Nov 19 '14 at 13:33

1 Answers1

2

This is the simplest way of converting ASCII value to character and finally to string:

int i = 123;
char c = (char)i;
string s = c.ToString();

In your example this should work like following:

text4 += (char)ascii + "-";
Denys Denysenko
  • 7,598
  • 1
  • 20
  • 30