byte b = (byte)'A';
char c = (char)65;

解决方案 »

  1.   

    不妨看看下面的例子private void TestChar() {
        char ch = 'a'; short ii = 65;
        this.textBox1.Text = "";
        this.textBox1.AppendText("The ASCII code of \'" + ch + "\' is: " + (short) ch + "\n");
        this.textBox1.AppendText("ASCII is " + ii.ToString() + ", the char is: " + (char) ii + "\n");
    }
      它的运行结果是The ASCII code of 'a' is: 97
    ASCII is 65, the char is: A强制转换,可以得以字符的编码,或者得到编码表示的字符。如果你需要的不是 short 型的编码,请参考第 1 条进行转换,即可得到 int 等类型的编码值。
      

  2.   

    char chA = Convert.ToChar(65);
    如果使用string类型,这样
    string s = new string((char)65,1);
    or
    byte[] bytes=System.Text.Encoding.ASCII.GetBytes(str);
    :)
      

  3.   

    ASCII->字符:(char)123字符->ASCII:
    char[] myArrayChar={'a'};
    byte[] myArrayByte=ASCIIEncoding.GetBytes(myArrayChar)
    myArrayByte 中包含获得的结果。注意,ASCII 只用于英文环境,多数情况下,应当使用 UnicodeEncoding 或者 UTF8Encoding