OMGKurtNilsen OMGKurtNilsen - 1 year ago 93
C# Question

C# Hexadecimal to char

I have a hexidecimal string with a length of 4, such as "003a".

What is the best way to convert this into a char? First convert to bytes and then to char?

Answer Source

Try this:

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


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


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