I have a List
. I would like to convert it into a >
List
where each int is unique. I was wondering if anyone had a
List> l = new List>();
l.Add(new List { 1, 2, 3, 4, 5, 6});
l.Add(new List { 4, 5, 6, 7, 8, 9 });
l.Add(new List { 8, 9, 10, 11, 12, 13 });
var result = (from e in l
from e2 in e
select e2).Distinct();
But these days I would actually write it as
var result2 = l.SelectMany(i => i).Distinct();