static void Main(string[] args) { //Covariance object myObj = "string"; Animal animal = new Bird(); object obj = new Bird(); //Contravariance Action<object> actObject = SetObject; Action<Bird> actString = actObject; actString.Invoke(new Bird()); //Covariance in Generic interfaces IComparer<Bird> birdComparer = new AnimalComparer(); birdComparer.Compare(bird1, bird2); ////Contravariance in Generic interfaces BirdCreator birdCreator = new BirdCreator(); ContraVariance(birdCreator); Console.ReadLine(); }
static void Main(string[] args) { BirdCreator birdCreator = new BirdCreator( ); ContraVariance(birdCreator); Console.ReadLine(); }