using System; using System.Collections.Generic; public class Test { static void Main(string[] args) { var set = new HashSet { new MyClass { Value = 1 }, new MyClass { Value = 2 } }; foreach (var x in set) Console.WriteLine(x.Value); } } class MyClass { public int Value { get; set; } public override int GetHashCode() => 0; }