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:
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, members cannot be marked as Overridable
, being not inheritable. Another typical example of not inheritable classes ...
Get Visual Basic® 2010 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.