I am trying to convert some data in hexadecimal into string using this code:
hex = hex.Replace("0x", "");
hex = hex.Trim();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < hex.Length; i += 2)
{
string hs = hex.Substring(i, 2);
stringBuilder.Append(Convert.ToChar(Convert.ToInt32(hs,16)));
}
Hex being in the format "0x53 0x50 0x31 0x32 0x33 0x34 0x35 0x36".
However, I keep getting an error
System.FormatException: 'Could not find any recognizable digits'
Hope to understand what is the issue and how to resolve it. Many thanks!