0

hi all,
i m new in c#.
I dont know how to convert hexadecimal value of a character into its charcter equivalent.
please help me in solving my problem.
thanx in advance.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by manjusaharan
0

You need to convert the Hex back into an int then convert the into to a char.

string sHex = "41"; // same as 'A'
byte newByte = byte.Parse(sHex, System.Globalization.NumberStyles.HexNumber);
// newByte now = "65"
int i = Convert.ToInt32(newByte.ToString()); // i now = 65
Char schar = Convert.ToChar(i);
// schar = 'A'

Hope someone else comes up with a better solution.

0

You need to convert the Hex back into an int then convert the into to a char.

string sHex = "41"; // same as 'A'
byte newByte = byte.Parse(sHex, System.Globalization.NumberStyles.HexNumber);
// newByte now = "65"
int i = Convert.ToInt32(newByte.ToString()); // i now = 65
Char schar = Convert.ToChar(i);
// schar = 'A'

Hope someone else comes up with a better solution.

Thanx A lot ,It works.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.