Created
August 18, 2014 16:57
-
-
Save mclasson/3e7b39f3282d0e38d082 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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