I have a string variable in Hex format which I need to convert to a standard ASCII string ; eg "48656C6C6F20576F726C64" should convert to "Hello World". I can't seem to find anything in the help files which actually helps with what should be a fairly common requirement. If anyone can throw light on this (and indeed the reverse conversion) I would be very grateful.

Hex convertion to string in C#
momsonrikky
pws111
Yes, well I have it working, if a little longwindedly!! here is the code
private string HexAsciiConvert(string hex)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= hex.Length - 2; i += 2)
{
sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hex.Substring(i, 2),
System.Globalization.NumberStyles.HexNumber))));
}
return sb.ToString();
}
However, I am sure that there must be a simpler way than a double conversion!
dhToday
jamesh1971
Kuldeep Deokule
Yes I suppose so. It's just so irritating that, with so much work that has supposedly gone into VS2005 C#, they can't even provide a simple conversion like this in a single shot. I'm sure that I can't be the only person in the world that needs to get the ascii equivalent to a hex string. It used to be so easy in VB!!!
Thanks for all the help anyway.