To access an object through an interface, the class definition for the object must explicitly determine that it implements the interface ...
For example, I might have the following:
interface IAnimal { public void Yelp(); }
and the following class:
class Dog { public void Yelp() {
Now the dog really squeals; however, since it does not declare that it implements IAnimal, I cannot do the following:
IAnimal poodle = new Dog(); poodle.Yelp();
To fix this, the definition for Dog should be changed to:
class Dog : IAnimal { public void Yelp() {
Notme
source share