string new1= "?\0\0R%?";
string temp = new1;
char[] char1 = temp.ToCharArray(0, temp.Length);
int count = temp.Length;
for (int i = 0; i < count; i++)
{
//转换成码值
Int16 aa = Convert.ToInt16(char1[i]);
//转换成16进制
string test = aa.ToString("X");
}
为什么Int16 aa = Convert.ToInt16(char1[i]); 从ASC码转换成码值会出错,比如本来结果应该是224的码值却转换成了63。请高手指点,谢谢
string temp = new1;
char[] char1 = temp.ToCharArray(0, temp.Length);
int count = temp.Length;
for (int i = 0; i < count; i++)
{
//转换成码值
Int16 aa = Convert.ToInt16(char1[i]);
//转换成16进制
string test = aa.ToString("X");
}
为什么Int16 aa = Convert.ToInt16(char1[i]); 从ASC码转换成码值会出错,比如本来结果应该是224的码值却转换成了63。请高手指点,谢谢
temp = System.Text.Encoding.ASCII.GetString(bytes, 0, i);接受到以后是ASCII,这种形式"?\0\0R%?",要转换成16进制的才可以正确判断数据,请问如何实现,谢谢
换成ascii 就是
0x3f,0,0,0x52,0x25,0x3f ,
不知你要什么??