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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With