Consider the following class design:
Code:
class Animal{
public string Speak(){
return "Speak";
}
}
class Cat : Animal{
public override Speak(){
return "Meow";
}
}
class Dog : Animal{
public override Speak(){
return "Woof";
}
}
Now we create a few instances and call the method:
Code:
Animal oTest;
oTest = new Cat();
oTest.Speak(); //returns "Meow"
oTest = new Dog();
oTest.Speak(); //returns "Dog"
In this case we are working with the type "Animal". It's the interface of the superclass that the other types are derived from. We create instances of two different concrete types and call the same method on each, but get a different result. The sub classes provide the implementation to the superclass interface.
Another example is something like the Console.Write() method which has many overloads. You call the method the same for different types. The method is polymorphic in that is handles each type in a different way.
Take a look at the
Wikipedia entry for Polymorphism as it relates to OOP. The examples are similar to mine.
-Peter