Covariance

This allows for implicit conversion of generic type parameters.
this allows more flexibility when dealing with class hierarchy.


Arrays

Covariance for arrays enables implicit conversion of an array of the derived class (or type) to an array of the base class (or type)
So a more derived type to a less derived type
This opertion is not type safe

object[] myArray = new String[10]; 

A cat[] is an animal[]




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext