public class Dog {
public virtual void Speak() {
Console.WriteLine("Woof");
}
}
most our dogs just go woof ...
public class Rottweiler : Dog {}
public class Mastiff : Dog {}
public class Shitzu : Dog {}
some need to do something completely different than the default
public class DogThatThinksItIsACat : Dog {
public override void Speak() {
Console.WriteLine("Meow");
}
}
some need to extend the default
public class TalkativeDog : Dog {
public override void Speak() {
Console.WriteLine("WoofWoofWoof");
base.Speak();
}
}
In this case 99% of the dogs will go "woof" so implementing the same method
in every one of their derived classes would not make alot of sense ...
however when we get to one that needs to change or extend the default
behavior we can override the default and provide our own.
Cheers,
Greg Young
MVP - C#
"thomson" <sa**********@yahoo.com> wrote in message
news:11*********************@q12g2000cwa.googlegro ups.com...
Can you give me a real time example where i can do this
Thanks in Advance
thomso