NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

8.2.1 Instance Constructors

Instance constructors initialize instances of a type and are run by the runtime environment when an instance is created. The formal parameter list of a constructor is subject to the same rules as the formal parameter list of a method. Constructors may be overloaded using the Overloads keyword.

All constructors (except for the constructors of type Object) must explicitly invoke another constructor as the first statement in the constructor method body. The statement can either invoke another of the type's instance constructors (that is, Me.New(…)), or it may invoke an instance constructor of the type's base type (that is, MyBase.New(…)). It is illegal for a constructor to invoke itself.

When a constructor's first statement is of the form MyBase.New(…), the constructor implicitly performs the initializations specified by the variable initializers of the instance data members declared in the type. This corresponds to a sequence of assignments that are executed immediately upon entry to the constructor and before the invocation of the direct base type constructor. The variable initializers are executed in the textual order they appear in the type declaration.

When a type declares only private constructors it is not possible for other types to derive from the type or create instances of the type (an exception being types nested within the type). Private constructors are commonly used in types that contain only shared members.

If a type contains no instance constructor declarations, a default constructor is automatically provided. The default constructor simply invokes the parameterless constructor of the direct base type. If the direct base type does not have an accessible parameterless constructor, an error occurs.

InstanceConstructorDeclaration ::=
 [ InstanceConstructorModifier+ ] Sub [ Attributes ] New
  
[ ( [ FormalParameterList ] ) ] LineTerminator
 [ Block ]
 
End Sub LineTerminator
InstanceConstructorModifier ::= AccessModifier | Overloads