LINQ Select distinct from a List?

У меня есть следующий список:


    class Person
    {
        public String Name { get; set; }
        public String LastName { get; set; }
        public String City { get; set; }

        public Person(String name, String lastName, String city)
        {
            Name = name;
            LastName = lastName;
            City = city;
        }
    }

    ...

    personList.Add(new Person("a", "b", "1"));
    personList.Add(new Person("c", "d", "1"));
    personList.Add(new Person("e", "f", "2"));
    personList.Add(new Person("g", "h", "1"));
    personList.Add(new Person("i", "j", "2"));
    personList.Add(new Person("k", "l", "1"));

Как получить список лиц, отличающихся от названия города?

Ожидаемые результаты:

Массив/коллекция списков (лиц), отличающихся от названия города:

result[0] = List<Person> where city name = "1"
result[1] = List<Person> where city name = "2"
result[n] = List<Person> where city name = "whatever"
6
задан 27 September 2011 в 16:06
поделиться