If you start from the hexadecimal representation of the value, and you want to work with it, you have to do it in several steps:
- First, translate this hexadecimal string representation of a byte array into a byte array
- Second, pass this byte array to the GetString() method of the chosen Encoding.
Something like:
using System.Globalization;
using System.Text;
public static byte[] ByteArrayFromHexaString(string hexa) {
int length = hexa.Length;
List<byte> result = new List<byte>();
bool isOdd = ((length & 1) == 1);
if (isOdd) {
result.Add(byte.Parse(hexa[0], NumberStyles.HexNumber));
}
string s;
for (int i = (isOdd) ? 1 : 0; i < length; i += 2) {
s = hexa.SubString(i, 2);
result.Add(byte.Parse(s, NumberStyles.HexNumber));
}
return result.ToArray();
}
public static string StringFromByteArray(byte[] bytes, Encoding encoding) {
return encoding.GetString(bytes);
}
You now have both methods you need to get a string from the hexadecimal representation of its encoded raw value.
Good luck. Hope this helps.