Search code examples
c#winformsbytehexsendkeys

Convert String to Byte(0x??)


I've made a window form application that send keys but in order to send keys I do this:

To send 'A' I have to write down MyFunction(0x41). 0x41 is a byte.

I can get the 41 as a string, but how do I convert it to a byte (of this format - 0x41)


Solution

  • You can cast it to an integer type:

    MyFunction((byte)'A');