Why would you declare a method as "virtual".
What is the benefit in using virtual?
The Virtual Modifier is used to mark that a methodproperty(ect) can be modified in a derived class by using the override modifier.
Example:
class A { public virtual void Foo() //DoStuff For A } class B : A { public override void Foo() //DoStuff For B //now call the base to do the stuff for A and B //if required base.Foo() }
2.1m questions
2.1m answers
60 comments
57.0k users