public Cat NestedCats() { Cat grandMother = new Cat(); Cat mother = new Cat(); Cat daughter = new Cat(); Cat grandDaughter = new Cat(); Cat son = new Cat(); daughter.AddDescendant(grandDaughter); mother.AddDescendant(son); mother.AddDescendant(daughter); grandMother.AddDescendant(daughter); return grandMother; }
public List<Cat> Cyclic() { var catA = new Cat { }; var catB = new Cat { }; var catC = new Cat { }; catC.AddDescendant(catA); catA.AddDescendant(catC); return new List<Cat> { catA, catB, catC }; }