c#怎么显示asc码汉字

如题所述

//ASCII码转字符: 
//单个字符
public static string Chr(int asciiCode)
  {
   if (asciiCode >= 0 && asciiCode <= 255)
   {
    System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
    byte[] byteArray = new byte[] { (byte)asciiCode };
    string strCharacter = asciiEncoding.GetString(byteArray);
    return (strCharacter);
   }
   else
   {
    throw new Exception("ASCII Code is not valid.");
   }
  }

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-12-23
最简单的
int ascii = (int)'中';
char cn = (char)ascii;
相似回答