Section 11.6. NotOverridable Methods and NotInheritable Classes


11.6. NotOverridable Methods and NotInheritable Classes

A method that is declared NotOverridable in a base class cannot be overridden in a derived class. A method that is declared Overridable in a base class can be declared Not-Overridable in a derived classthis prevents overriding the method in classes that inherit from the derived class. All classes derived from the class that contains the NotOverridable method use that class's method implementation. Methods that are declared Private are implicitly NotOverridable.

A class that is declared NotInheritable cannot be a base class (i.e., a class cannot inherit from a NotInheritable class). All methods in a NotInheritable class are implicitly NotOverridable. A NotInheritable class is the opposite of a MustInherit class. A NotInheritable class is a concrete class that cannot act as a base class, whereas a MustInherit class is an abstract class that is intended as a base class. Class String is a NotInheritable class.

Common Programming Error 11.4

Attempting to inherit a NotInheritable class is a compilation error.




Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net