我的服务器段接受了“40 30 31 52 44 “这是一个ascII的格式我怎末能把它转化为字符?
例如:“40 30 31 52 44 “变为“@   0  1  R  D“
谢谢了!

解决方案 »

  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"); 
    char cn = ''中''; short uc = 22478; 
    this.textBox1.AppendText("The Unicode of \''" + cn + "\'' is: " + (short) cn + "\n"); 
    this.textBox1.AppendText("Unicode is " + uc.ToString() + ", the char is: " + (char) uc + "\n"); 

      它的运行结果是 The ASCII code of ''a'' is: 97 
    ASCII is 65, the char is: A 
    The Unicode of ''中'' is: 20013 
    Unicode is 22478, the char is: 城 
      

  2.   

    string str="65 66 67 68 69";//变为“A   B  C  D  E“
    string[] a=str.Split(' ');
    string b="";
    for(int i=0;i<a.Length;i++)
    {
                  b+=" "+((char)(Convert.ToInt32(a[i]))).ToString();
    }

    Response.Write(b);
      

  3.   

    public string HexToStr(string sourceStr)
    {
    string retStr = "";
    byte temp = 0;
    for(int i=0;i<sourceStr.Length / 2;i++)
    {
    temp = Convert.ToByte(sourceStr.Substring (2*i,2),16);
    retStr += System.Text.Encoding.ASCII.GetString (new byte[]{temp})+" ";   
    }
    return retStr;
    }
      

  4.   

    HexToStr("4030315244") 得到 --"@01RD
      

  5.   

    例如:
    int i=65;
    char c=(char)i;
    那么c就变成A了