Hi everyone,
I have some doubts about override- virtual- new keywords.
I think that all methods who include override keywords are also virual methods since we are also able to override these kinds of overriden methods.
THe following code snippet demonstrate my opinion.
So I would like to ask that whether I am wrong or correct. If I am wrong, please make me correct.
class VirtualClass
{
public virtual void VirtualMethod()
{
Console.WriteLine("VirtualClass:VirtualMethod");
}
}
class OverrideClassA : VirtualClass
{
public override void VirtualMethod()
{
Console.WriteLine("OverrideClassA:VirtualMethod");
base.VirtualMethod();
}
}
class OverrideClassB : OverrideClassA
{
public override void VirtualMethod()
{
Console.WriteLine("OverrideClassB:VirtualMethod");
base.VirtualMethod();
}
} Thanks,Mert

override- virtual- new keywords
JapanFred
You can call the base implementation of VirtualMethod() using the base pointer like this:
base.VirtualMethod();
Regards,
-chris
Alex Barry
Thanks for the quick reply and I also wonder about something.
class OverrideClassA : VirtualClass
{
public override void VirtualMethod()
{
Console.WriteLine("OverrideClassA:VirtualMethod");
base.VirtualMethod();
}
}
At the above class which is cut from the first reply's code snippet,
is VirtualMethod() method the one which is virtual member of that class
Thanks
dwielgosz
SuriyaPrakash
override modifier overrides the implementation of a class's virtual member, and at the same time, it inherits all the characteristics of the virtual member. At least that's the specification says.
Regards,
-chris