group object with equal collections
- by Jeroen
Hi,
Suppose 2 classes, Person and Pet. Each person has a collection of 1 or more pets.
How do i group the Person in to a collection where they share the same pets.
Example:
Person 1: Cat, Dog, Spider
Person 2: Cat, Spider, Snake
Person 3: Dog
Person 4: Spider, Cat, Dog
Person 5: Dog
What i want as a result is this:
Group 1: Person 1, Person 4
Group 2: Person 3, Person 5
Group 3: Person 2
How do i achieve this using LINQ?