using System.Collections.Generic;
public string Name { get; set; }
public class Cat : Animal { }
public class Dog : Animal { }
public static void Main()
Console.WriteLine(GetFilteredAnimals("Pe", GetCats));
private static List<Cat> GetCats()
return new List<Cat>() { new Cat { Name = "Sphinx" }, new Cat { Name = "Persian" } };
private static List<Dog> GetDogs()
return new List<Dog>() { new Dog { Name = "Bulldog"}, new Dog { Name = "Dalmatian" } };
private static List<Animal> GetFilteredAnimals(string f, Func<List<Animal>> method)
return animals.Where(a => a.Name.StartsWith(f)).ToList<Animal>();