linq query in list<list<T>>

Viewed 52

I want to extract only the elements of List corresponding to a specific index from List<List>.
Tried to do this using LINQ Query and not For or Foreach, but I wasn't lucky
I want the result like below

List<List<string>> list = new List<List<string>>();
list.Add(new List<string> { "1", "2", "3" });
list.Add(new List<string> { "A", "B", "C" });

// expectation result List : index 1
// { "2", "B" }
1 Answers

Use Select.

int index;
list.Select(l => l[index]);
Related