Introduction
This article gives an idea, how to hold the object of different classes in array
of another class.
Suppose I have three classes Bird, Human and Fish and another class is Holder to
hold the object of those three classes (Bird, Human, fish).
Object Holder Class
But we can't create object array class with the reference of bird, human and
fish class. Because we were the error “Can Not Implicitly Convert type Bird to
System. Array” for solve this error I Used interface.
Suppose I have one Interface and it define one method Talk ().which implements
all those three classes (Bird, Human, Fish) like.
Now in holder class we can hold the all object of different classes in array
variable Of Interface IAnimal Type by below code: