NotOverridable Keyword

You can mark an overridden method or property as NotOverridable so that derived classes cannot override them again. The NotOverridable keyword cannot be used versus methods or properties that do not override a base member. Continuing the example of the Contact class previously defined, the NotOverridable keyword can be used as follows:

Public NotOverridable Overrides Function FullName() As String    Return String.Concat(MyBase.FullName(), ": ", Email)End Function

In this way the FullName method within the Contact class overrides the base class, but derived classes cannot override it again. NotOverridable is used only within derived classes that override the base class’s members because in a ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.