C # Hex to char

I have a hexadecimal string of length 4, for example "003a".

How can I convert this to char? Convert to bytes first and then to char?

+8
c #
source share
3 answers

Try the following:

(char)Int16.Parse("003a", NumberStyles.AllowHexSpecifier); 

or

 System.Convert.ToChar(System.Convert.ToUInt32("003a", 16)); 

or

 string str = ""; for(int i = 0; i<myHex.Length; i += 4) str += (char)Int16.Parse(myHex.Substring(i, 4), NumberStyles.AllowHexSpecifier); 
+15
source share

Analyze it first with Int32.Parse() , then use Convert.ToChar() .

0
source share

You can use the following code:

 label1.Text = System.Convert.ToChar(System.Convert.ToUInt32("0x00AC", 16)).ToString(); 
0
source share

All Articles