NotInheritable Keyword

There are situations in which you might want to prevent inheritance from your classes. This can be useful if you do not want a client to modify in any way the base object’s behavior and its members. To accomplish this, you simply need to mark a class with the NotInheritable keyword. The following code shows an example of a class that cannot be derived:

Public NotInheritable Class BusinessPerson    Inherits Person    Public Property Email As String    Public Property Title As String    Public Property BusinessPhone As StringEnd Class

As you can see, the BusinessPerson class is marked as NotInheritable and cannot be derived by other classes. It can still inherit from other classes but, obviously, ...

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.