Tag: Hexadecimal to ascii conversion

Sample C# code to convert Hexadecimal String to ASCII

The following C# code sample can be used for converting a Hexadecimal String(hex string) to ASCII.


private string HexString2Ascii(string hexString)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= hexString.Length - 2; i += 2)
{
sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
}
return sb.ToString();
}