fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var list = new List<Fact> () {
  10. new Fact { Thing = "Roses are", Color = 0xFF0000 },
  11. new Fact { Thing = "Roses are", Color = 0xFF0000 },
  12. new Fact { Thing = "Violets are", Color = 0x0000FF },
  13. new Fact { Thing = "Sugar is", Color = 0x1337 },
  14. new Fact { Thing = "Sugar is", Color = 0x1337 },
  15. };
  16.  
  17. foreach (var item in list.Distinct()) {
  18. Console.WriteLine ("{0:x} {1:x}", item.Thing, item.Color);
  19. }
  20. }
  21. }
  22.  
  23.  
  24. public class Fact
  25. {
  26. public string Thing { get; set; }
  27. public int Color { get; set; }
  28. }
Success #stdin #stdout 0.04s 34000KB
stdin
Standard input is empty
stdout
Roses are ff0000
Roses are ff0000
Violets are ff
Sugar is 1337
Sugar is 1337