//Prepare test data. Could be a set returned | |
//from a database query | |
var list = new List<int>(); | |
for (int i = 0; i < 1000000; i++) | |
{ | |
list.Add(i); | |
} | |
//Prepare a list to hold the results | |
//E.g list of all users born a certain year | |
var listOfInts = new List<IEnumerable<int>>(); | |
for (int i = 0; i < 10; i++) | |
{ | |
//Select from the large list all users | |
//that satisfy the criteria | |
listOfInts.Add(list.Where(a => a == i)); | |
} | |
//Now, loop through all years and select the | |
//first user for every year | |
foreach(var l in listOfInts) | |
{ | |
Console.WriteLine(l.First()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment