using System.Collections.Generic;
public static void Main()
var groups = Person.MergePerson(Person.r);
foreach (var group in groups)
Console.WriteLine("Группа: " + group.Key);
foreach (Person person in group.Value)
Console.WriteLine(@"Person {0} {1} {2}", person.a, person.b, person.ndx);
public Person(string a, string b, int ndx)
public static List<Person> r = new List<Person> {
new Person("10", "1", 0),
new Person("10", "0", 1),
new Person("10", "2", 2),
new Person("13", "4", 3),
new Person("11", "2", 4),
new Person("11", "3", 5),
new Person("12", "3", 6),
new Person("14", "5", 7),
new Person("13", "5", 8),
public static Dictionary<string, List<Person>> MergePerson(List<Person> r)
return new Dictionary<string, List<Person>>
{"a", r.GroupBy(x => x.a).Where(y => y.Count() > 1).SelectMany(z => z).ToList()},
{"b", r.GroupBy(x => x.b).Where(y => y.Count() > 1).SelectMany(z => z).ToList()}