static void Main() { var sets = new SetCombiner <int> { { 1, 2 }, { 3, 4 }, { 2, 4 }, { 9, 10 }, { 9, 12 } }; sets.Combine(); foreach (var set in sets) { Console.WriteLine("{" + string.Join(",", set.OrderBy(x => x)) + "}"); } }
static void Main() { var sets = new SetCombiner <int> { { 1, 2 }, { 3, 4 }, { 2, 4 }, { 9, 10 }, { 9, 12 } }; sets.Combine(); foreach (var set in sets) { // edited for unity: original implementation // Console.WriteLine("{" + // string.Join(",", set.OrderBy(x => x)) + "}"); StringBuilder sb = new StringBuilder(); foreach (int i in set.OrderBy(x => x)) { if (sb.Length != 0) { sb.Append(','); } sb.Append(i); } Console.WriteLine("{" + sb + "}"); } }