Monday 15 April 2013

How can convert a hex string into a string whose ASCII values have the same value in C#? -


Assume that I have a string with hex value. For example:

  string command "0xABCD1234";   

How do I change that string to another string (for example, string codedString = ... ) ASCII-encoded representation of this new string Is binary content as the original string?

I need to do this because I have a library from a hardware manufacturer that can transmit the piece from its hardware to the other part of the hardware as the input of their string as an input , But when I try to send "AA", then I expect the SPI to broadcast Binary 10101010, but instead it is transmitted to AA's ASCI representation Not which is 0110000101100001.

In addition, this hex string will be 32 hex characters (that is, 256 bit long).

  string command = "aa"; Int num = int.Parse (command, number style. Hysnumber); String Bit = Convert ToString (num, 2); // & lt; - 10101010    

No comments:

Post a Comment