[Public|Private|Protected|Friend||Protected Friend][MustInherit|NotInheritable] Class name [statements] End Class
The Class statement syntax has these parts:
Part | Description |
---|---|
Public | Optional. Entities declared with the Public modifier have public access. There are no restrictions on the use of public entities |
Private | Optional. Entities declared with the Private modifier have private access. A private entity is accessible only within its declaration context, including any nested entities. |
Protected | Optional. Entities declared with the Protected modifier have protected access. Protected access can only be specified on members of types (both regular type members and nested types), although there are different access rules for the two. A protected type member contained in a type is accessible to entities contained in a derived type, provided the access takes place through the derived type. A protected type nested in a type is accessible to entities contained in a derived type, provided the access takes place through the base type (since nested types are not inherited). Protected access is not a superset of friend access. |
Friend | Optional. Entities declared with the Friend modifier have friend access. An entity with friend access is accessible only within the program that contains the entity declaration. |
Protected Friend | Optional. Entities declared with the Protected Friend modifiers have the union of protected and friend accessibility. |
MustInherit | Optional. Indicates that the Class contains methods that must be implemented by a deriving class. Instances of must-inherit classes cannot be created. |
NotInheritable | Optional. Indicates that the Class is a class from which no further inheritance is allowed. |
name | Required. Name of the Class; follows standard variable naming conventions. |
statements | Optional. Statements which comprise the variables, properties, events, and methods of the class. |
Within a Class block, members are declared as either Public, Private, Protected, Friend, or Protected Friend using the appropriate declaration statements. Anything declared as Private is visible only within the Class block. Anything declared as Public is visible within the Class block, as well as by code outside the Class block. Anything not explicitly declared is Public by default, except for those fields which default to Private. Public variables serve as properties of the class, as do properties explicitly declared usingProperty declarations. Default properties and methods for the class are specified in their declarations using the Default keyword. See the individual declaration statement topics for information on how this keyword is used.
Binding of unqualified names in nested classes will search the members of the class itself, then the members of its containing class, and so on out to the outermost containing class. Private members of outer classes can be referenced but an error will be given for references to instance members of containing classes.
Nested classes cannot inherit from their containing class.
Inherits Statement | Interface Statement