How to convert string data?

I using terminal program to get my data. U can load it at: http://bray.velenje.cx/avr/terminal/
My hardware send string data to computer, when terminal program display in hex format, data is
"55 AA 08 20 00 28" and when it display in string data, it is "U@<00>H".

How do i convert U@<00>H to 55 AA 08 20 00 28 and from 55 AA 08 20 00 28 to U@<00>H

Thank you!



Answer this question

How to convert string data?

  • MBursill

    You can use the char data type. You can convert a single character to an interger or it's equivalend hex value using.

    c = Char.Parse("A")

    Console.WriteLine("{0}", Convert.ToInt32(c))

    Console.WriteLine("{0:X}", Convert.ToInt32(c))

    Doing the other way around is also simple

    c = Convert.ToChar(65)

    Console.WriteLine("{0}", c)

    You will have to find a converter from a string representing a hex value to integer. The rest is juste a simple string parsing to seperate each value from the space.



  • How to convert string data?