Converting a string array to a byte array

arrays, byte, c#, string

Solution

This will fail for anything that can't be parsed by `byte.Parse`

var str = new[] {"5", "168", "188", "28", "29", "155"};
var byt = str.Select(byte.Parse).ToArray();

Problem

Ok, before anyone attempts to label this as a duplicate, I am not asking for a string to a byte array. I want a string array, containing something similar like this: {"5","168","188","28","29","155"} to be converted to a byte array. I have searched, and was only able to find string to byte array, which is quite different. Thanks. Edit: the array will be preset so that each member is parsable through byte.Parse, so this is not an issue.

Original source

Related problems