I have got a string for instance:
"FF AA 1A 23 DF"
The only thing I want to get is a byte array that contains the following bytes:
[FF, AA, 1A, 23, DF..]
Somehow can I do a conversion like this?
I have got a string for instance:
"FF AA 1A 23 DF"
The only thing I want to get is a byte array that contains the following bytes:
[FF, AA, 1A, 23, DF..]
Somehow can I do a conversion like this?
Try Linq: Split
and Convert
string source = "FF AA 1A 23 DF";
byte[] result = source
.Split(' ') // Split into items
.Select(item => Convert.ToByte(item, 16)) // Convert each item into byte
.ToArray(); // Materialize as array