我正在尝试将字符串中的十六进制值转换为 ASCII 值和 UTF8 值。但是当我执行以下代码时,它会打印出与我输入的相同的十六进制值
string hexString = "68656c6c6f2c206d79206e616d6520697320796f752e";
System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding();
byte[] dBytes = encoding.GetBytes(hexString);
//To get ASCII value of the hex string.
string ASCIIresult = System.Text.Encoding.ASCII.GetString(dBytes);
MessageBox.Show(ASCIIresult, "Showing value in ASCII");
//To get the UTF8 value of the hex string
string utf8result = System.Text.Encoding.UTF8.GetString(dBytes);
MessageBox.Show(utf8result, "Showing value in UTF8");