Geeks With Blogs


My blog is worth $14,678.04.
How much is your blog worth?

Totzkeeeeee's Blog Just because I can... December 2010 Entries
Distinctly LINQ – Getting a Distinct List of Objects
Let’s say that you have a list of objects that contains duplicate items and you want to extract a subset of distinct items. This is pretty straight forward in the trivial case where the duplicate objects are considered the same such as in the following example: List<int> ages = new List<int> { 21, 46, 46, 55, 17, 21, 55, 55 }; IEnumerable<int> distinctAges = ages.Distinct(); Console.WriteLine("Distinct ages:"); foreach (int age in distinctAges) { Console.WriteLine(age); } /* This ......

Posted On Monday, December 6, 2010 9:13 AM

Copyright © David Totzke | Powered by: