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.

Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.