i need a conversion code on c# to convert ASCII to Binary..
I'm doing a project on serial port and i need to display the received data in hex.. i have declared the received data as string. I used this code:
public static byte[] ConvertToBinary(string Rxstring)
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(Rxstring);
}
p/s: Rxstring is the string variable that i declared for received data.
And when on the serial port testing, when i send ( for eg: #41 ) and my display must also be displaying #41. But on my display, it shows 'A'.Which it's outcome is not what i wanted. I think it's reading the received data in ASCII. Is it the code above don't seems to work for the conversion?
Thanks! =)