C# - How to extract a list of one particular array member from a list of arrays -


given list of arrays, i'd extract second member of each array in list list of strings.

for example, list of arrays contains: {"1", "a", "x"} {"2", "b", "y"} {"3", "c", "z"}

then i'd output list of strings containing: "a", "b" & "c"

so say:

list<string> mylistofstrings = new list<string>();  mylistofstrings.addrange(???) 

if know sure arrays have element @ index 1, linq in single line:

var mylistofstrings = listofarrays.select(a => a[1]).tolist(); 

demo.


Comments