MDabaan

Helloz all,

am writting a project using C#, i have a data stroed in the SQL DB where some fields are in hexadecimal format, i want to show them on datagridview on the windows form, how can i convert them to the string values of them




Re: Windows Forms General Convertinn from hexadecimal to string in C#

TilakGopi

Where r u storing the data after retrieving

Code snippet will help me a lot understanding the problem..

Thanx

Ch.T.Gopi Kumar






Re: Windows Forms General Convertinn from hexadecimal to string in C#

Brian Kramer

Moving to the Windows Forms forum. Please use this forum for C++ language issues only. Thanks.



Re: Windows Forms General Convertinn from hexadecimal to string in C#

timvw

The following code could inspire you:

static void Main( string[] args )
{
string byteMsg =
"3C-68-74-6D-6C-3E-0D-0A-20-20
-20-20-3C-68-65-61-64";

string[] parts = byteMsg.Split( new char[] { '-' } );
StringBuilder stringBuilder = new StringBuilder();
for( int i = 0; i < parts.Length; ++i )
{
stringBuilder.Append( (char) Convert.ToInt32( partsIdea, 16 ) );
}

Console.WriteLine( "msg: {0}", stringBuilder.ToString() );

Console.WriteLine( "Press any key to continue..." );
Console.ReadKey();
}