“my name” 的Unicode的十六进制是“6D00790020006E006D006500” 用C#代码怎么把 string aa="6D00790020006E006D006500";
转换成"my name"

解决方案 »

  1.   

                string aa = "6D00790020006E006D006500";
                string[] strArry = Regex.Replace(aa, @"(\w{2})0{2}", "$1,").Split(',');
                for (int i = 0; i < strArry.Length-1; i++)
    {
                    Console.Write("{0}",(char)Convert.ToInt16(strArry[i], 16));
                }
      

  2.   

    string hexValues = "48 65 6C 6C 6F 20 57 6F 72 6C 64 21";
    string[] hexValuesSplit = hexValues.Split(' ');
    foreach (String hex in hexValuesSplit)
    {
        // Convert the number expressed in base-16 to an integer.
        int value = Convert.ToInt32(hex, 16);
        // Get the character corresponding to the integral value.
        string stringValue = Char.ConvertFromUtf32(value);
        char charValue = (char)value;
        Console.WriteLine("hexadecimal value = {0}, int value = {1}, char value = {2} or {3}",
                            hex, value, stringValue, charValue);
    }
    /* Output:
        hexadecimal value = 48, int value = 72, char value = H or H
        hexadecimal value = 65, int value = 101, char value = e or e
        hexadecimal value = 6C, int value = 108, char value = l or l
        hexadecimal value = 6C, int value = 108, char value = l or l
        hexadecimal value = 6F, int value = 111, char value = o or o
        hexadecimal value = 20, int value = 32, char value =   or
        hexadecimal value = 57, int value = 87, char value = W or W
        hexadecimal value = 6F, int value = 111, char value = o or o
        hexadecimal value = 72, int value = 114, char value = r or r
        hexadecimal value = 6C, int value = 108, char value = l or l
        hexadecimal value = 64, int value = 100, char value = d or d
        hexadecimal value = 21, int value = 33, char value = ! or !
    */
      

  3.   

    重点是:
    hex 是两个字符组合的十六进制:
     int value = Convert.ToInt32(hex, 16);
     string stringValue = Char.ConvertFromUtf32(value);