How can I take a List and turn it into a byte array.
I thought there might be some clever LINQ options for it but am unsure eg/List.ForEach
Depends on which encoding you want to use to convert the string
to a byte[]
but here's a sample for ASCII. It can be substituted for pretty much any encoding type
List<string> data = ...
byte[] dataAsBytes = data
.SelectMany(s => Text.Encoding.ASCII.GetBytes(s))
.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