Inheritance in Visual Basic

Public 
There are no restrictions on the use of a class declared as Public.

Private 
A Private class is accessible only within its “declaration context” including any nested entities. A nested procedure is an example of a nested entity. A Public variable in a Private class is accessible from inside the class, but not from outside that class.

Protected 
Protected means that elements are accessible only from within their own class or from a derived class. Protected can also be used with the Friend keyword. When they’re used together, elements are accessible from the same assembly, from their own class, and from any derived classes.

Friend 
Friend access means that elements are accessible only within the program. Friend is the default access modifer for any class that does not have a modifier.

Shadows 
The keyword Shadows means that when a member of a derived class has the same name as a member of the same type in the base class, then the member in the derived class entirely replaces all variations of the method from the base class, leaving the derived class with only a single version of the method, that is, the one created in the derived class. Shadows does not extend an interface, but rather replaces existing methods. In addition, Shadows allows a member type to “override” any other member type. Thus, for example, a method can “override” a property. Keep in mind that the Shadows keyword is not required, since Shadows is the default. But if you leave it off, the compiler will warn that the method is being shadowed, not overloaded.

MustInherit 
MustInherit means that the class cannot be instantiated (DerivedObjAs New BaseObj) but rather must be inherited. See this article for more information.

NotInheritable 
NotInheritable means that the class cannot be inherited (DerivedObjInherits BaseObj) but rather must be instantiated. See this article for more information.

Inherits 
The current class Inherits the attributes, fields, properties, methods, and events from another class. In other words, it’s as though the base class is part of your program.

Implements 
Specifies one or more interfaces, or interface members, that will be implemented in the class.

An Interface is similar to a class, but there is no implementation code, only the properties, methods, and events that classes can implement. This gives developers the flexibility to seperate definitions from implementation and allows future changes to be made without recoding everything.

This entry was posted in copy/paste, study. Bookmark the permalink.

Comments are closed.