using System;
using System.Linq;
using System.Collections.Generic;
public class Test
{
public static void Main()
{
var list = new List<Fact> () {
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<Fact> GetFacts(IEnumerable<Fact> list) {
return list.Select(x => new { x.Thing, x.Color } ).Distinct().Select(x => new Fact { Thing = x.Thing, Color = x.Color });
}
}
public class Fact
{
public string Thing { get; set; }
public int Color { get; set; }
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWM7CiAKcHVibGljIGNsYXNzIFRlc3QKewogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKICAgICAgICB7CiAgICAgICAgICAgICAgICB2YXIgbGlzdCA9IG5ldyBMaXN0PEZhY3Q+ICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBGYWN0IHsgVGhpbmcgPSAiUm9zZXMgYXJlIiwgQ29sb3IgPSAweEZGMDAwMCB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgRmFjdCB7IFRoaW5nID0gIlJvc2VzIGFyZSIsIENvbG9yID0gMHhGRjAwMDAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3IEZhY3QgeyBUaGluZyA9ICJWaW9sZXRzIGFyZSIsIENvbG9yID0gMHgwMDAwRkYgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3IEZhY3QgeyBUaGluZyA9ICJTdWdhciBpcyIsIENvbG9yID0gMHgxMzM3IH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBGYWN0IHsgVGhpbmcgPSAiU3VnYXIgaXMiLCBDb2xvciA9IDB4MTMzNyB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICBmb3JlYWNoKHZhciBpdGVtIGluIEdldEZhY3RzKGxpc3QpKSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUgKCJ7MDp4fSB7MTp4fSIsIGl0ZW0uVGhpbmcsIGl0ZW0uQ29sb3IpOwogICAgICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAKICAgICAgICBwdWJsaWMgc3RhdGljIElFbnVtZXJhYmxlPEZhY3Q+IEdldEZhY3RzKElFbnVtZXJhYmxlPEZhY3Q+IGxpc3QpIHsKICAgICAgICAgICAgcmV0dXJuIGxpc3QuU2VsZWN0KHggPT4gbmV3IHsgeC5UaGluZywgeC5Db2xvciB9ICkuRGlzdGluY3QoKS5TZWxlY3QoeCA9PiBuZXcgRmFjdCB7IFRoaW5nID0geC5UaGluZywgQ29sb3IgPSB4LkNvbG9yIH0pOwogICAgICAgIH0KfQogCnB1YmxpYyBjbGFzcyBGYWN0CnsKICAgIHB1YmxpYyBzdHJpbmcgVGhpbmcgeyBnZXQ7IHNldDsgfQogICAgcHVibGljIGludCBDb2xvciB7IGdldDsgc2V0OyB9Cn0KIA==