I have a List<List<int>>
. I would like to convert it into a List<int>
where each int is unique. I was wondering if anyone had an elegant solution to this using LINQ.
I would like to be able to use the Union method but it creates a new List<> everytime. So I'd like to avoid doing something like this:
List<int> allInts = new List<int>();
foreach(List<int> list in listOfLists)
allInts = new List<int>(allInts.Union(list));
Any suggestions?
Thanks!