using System; using System.Linq; using System.Collections.Generic; public class Test { public static void Main() { var list = new List () { new Fact { Thing = "Roses are", Color = 0xFF0000 }, new Fact { Thing = "Roses are", Color = 0xFF0000 }, new Fact { Thing = "Violets are", Color = 0x0000FF }, new Fact { Thing = "Sugar is", Color = 0x1337 }, new Fact { Thing = "Sugar is", Color = 0x1337 }, }; foreach (var item in GetFacts(list)) { Console.WriteLine ("{0:x} {1:x}", item.Thing, item.Color); } } public static IEnumerable GetFacts(IEnumerable list) { return list.Distinct(); } } public class Fact { public string Thing { get; set; } public int Color { get; set; } public override bool Equals (object obj) { if (obj == null) return false; var x = obj as Fact; if (x == null) return false; return this.Thing == x.Thing && this.Color == x.Color; } public override int GetHashCode () { // http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode unchecked { int hash = 17; hash = hash * 23 + this.Thing.GetHashCode (); hash = hash * 23 + this.Color.GetHashCode (); return hash; } } }