Question for you about virtual functions

Is there a way in a subclass to mark a particular function as "final". That is, I have base class A. A declares a virtual function. B inherits, and overrides the function. C inherits B. I want to prevent C from overrideing the function again, but still have it work virtually as far as A and B are concerned.

 

Any help?

Print | posted on Thursday, April 10, 2008 10:09 AM

Feedback

# re: Question for you about virtual functions

left by Jeff Hunsaker at 4/10/2008 1:32 PM Gravatar
Mark the method in class B as "sealed":

public class ClassB : ClassA
{
protected sealed override void Foo()
{
base.Foo();
}
}
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: