public class Derived : Base
{
public override void SomeMethod() {
base.SomeMethod(); // note lower case 'b'
Console.WriteLine "B";
}
}
base is a keyword that allows you to invoke a method on your direct base class
Regards
Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<vr**************@news04.bloor.is.net.cable.rogers .com>
I have a question on calling parent class... What I want to do is: when
calling the derived class, it automatically executes the parent's method, is
it possible?
// main code:
Derived d = new Derived();
d.SomeMethod();
public class Base
{
public virtual void SomeMethod() {
Console.WriteLine "A";
}
}
public class Derived : Base
{
public override void SomeMethod() {
// this.parent.SomeMethod();
Console.WriteLine "B";
}
}
Is there a way to call the derived class and then both "A" and "B" will be
printed out?
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004
[microsoft.public.dotnet.languages.csharp]