I'm using C#.
I have a string array as follow: "1,2,3,4,5,..."
I'm trying to convert the string array to byte array as follow []{1,2,3,4,5,...}
What is the best way to do that?
Thanks.
I'm using C#.
I have a string array as follow: "1,2,3,4,5,..."
I'm trying to convert the string array to byte array as follow []{1,2,3,4,5,...}
What is the best way to do that?
Thanks.
Try using Linq:
string source = "1,2,3,4,5";
byte[] result = source
.Split(',')
.Select(item => byte.Parse(item))
.ToArray();
byte[] byteArray = str.Select(s => Convert.ToByte(s, 16)).ToArray();
Str represent string[]. If you have string you should string[] str = string.Split(',');