I have the following class
public class Element
{
public List<int> Ints
{
get;private set;
}
}
Given a List<Element>
, how to find a list of all the Ints
inside the List<Element>
using LINQ?
I can use the following code
public static List<int> FindInts(List<Element> elements)
{
var ints = new List<int>();
foreach(var element in elements)
{
ints.AddRange(element.Ints);
}
return ints;
}
}
But it is so ugly and long winded that I want to vomit every time I write it.
Any ideas?