using System.Collections.Generic;
public static void Main()
private static void Scenario1()
List<PetInterface> petInterfaceList = new List<PetInterface>();
petInterfaceList.Add(dog);
petInterfaceList.Add(cat);
private static void Scenario2()
List<Pet> petList = new List<Pet> { dog, cat };
List<PetInterface> petInterfaceList = petList;
public interface PetInterface
public int petId { get; set; }
public String name { get; set; }
public int petId { get; set; }
public String name { get; set; }
public class Dog : Pet, PetInterface
public class Cat : Pet, PetInterface