Class Modifiers

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.

Abstract Classes

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:

A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract members.

Final Classes

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.

Example

//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:

Classes