C#hex到char
我有一个长度为4的hex字符串,例如“003a”。
将此转换为char的最佳方法是什么? 首先转换为字节,然后转换为char?
试试这个:
(char)Int16.Parse("003a", NumberStyles.AllowHexSpecifier);
要么
System.Convert.ToChar(System.Convert.ToUInt32("003a", 16));
要么
string str = ""; for(int i = 0; i
首先使用Int32.Parse()
解析它,然后使用Convert.ToChar()
。
您可以使用以下代码:
label1.Text = System.Convert.ToChar(System.Convert.ToUInt32("0x00AC", 16)).ToString();