A class declaration may optionally include a sequence of class modifiers:
class-modifiers:
class-modifier
class-modifiers class-modifier
class-modifier:
Public
Friend
Abstract
Final
It is a compile error for the same modifier to appear multiple times in a class declaration. The Public and Friend modifiers determine class visibility scope. The Abstract and Final modifiers are described below.
The abstract modifier is used to indicate that a class is incomplete and that it can be used only as a base class. An abstract class differs from a non-abstract class in the following ways:
It is not possible to explicitly create an abstract class instance, and it is a compile error to use the New operator on an abstract class. While it is possible to have variables and values, which compile-time types are abstract, such variables and values at the runtime will necessarily either be empty (Null) or contain references to instances of non-abstract classes derived from this abstract type.
An abstract class is permitted (but not required) to contain abstract members.
An abstract class cannot be final.
A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract members.
The Final modifier is used to prevent derivation from a class. A compile error occurs if a final class is specified as the base class of another class.
The Final modifier is usually used to prevent an unintended derivation, but it also enables certain runtime optimizations. For example, it is possible to transform virtual method invocations into non-virtual invocations, as it is known that this class has no delegates.
//Class, available in the entire assembly, as well as in assemblies
//where this assembly is referenced to
Public Class Class1
End Class;
//Class available in entire assembly
Friend Class Class2
End Class;
//Abstract class
Abstract Class Class3
End Class;
//Class derived from abstract
Class Class4: Class3
End Class;
//Final class that cannot have derived classes
Final Class Class5
End Class;
See also: