Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specification 17 Classes 17.10 Instance constructors
Paragraph 11 An instance constructor is a member that implements the actions required to initialize an instance of a class. 2 Instance constructors are declared using constructor-declarations: constructor-declaration : attributesopt constructor-modifiersopt constructor-declarator constructor-body constructor-modifiers : constructor-modifier constructor-modifiers constructor-modifier constructor-modifier : public protected internal private extern constructor-declarator : identifier ( formal-parameter-listopt ) constructor-initializeropt constructor-initializer : : base ( argument-listopt ) : this ( argument-listopt ) constructor-body : block ;
Paragraph 21 A constructor-declaration may include a set of attributes (§24), a valid combination of the four access modifiers (§17.2.3), and an extern (§17.5.7) modifier. 2 A constructor declaration is not permitted to include the same modifier multiple times.
Paragraph 31 The identifier of a constructor-declarator must name the class in which the instance constructor is declared. 2 If any other name is specified, a compile-time error occurs.
Paragraph 41 The optional formal-parameter-list of an instance constructor is subject to the same rules as the formal-parameter-list of a method (§17.5). 2 The formal parameter list defines the signature (§10.6) of an instance constructor and governs the process whereby overload resolution (§14.4.2) selects a particular instance constructor in an invocation.
Paragraph 51 Each of the types referenced in the formal-parameter-list of an instance constructor must be at least as accessible as the constructor itself (§10.5.4).
Paragraph 61 The optional constructor-initializer specifies another instance constructor to invoke before executing the statements given in the constructor-body of this instance constructor. 2 This is described further in §17.10.1.
Paragraph 71 When a constructor declaration includes an extern modifier, the constructor is said to be an external constructor.
Paragraph 81 Because an external constructor declaration provides no actual implementation, its constructor-body consists of a semicolon. 2 For all other constructors, the constructor-body consists of a block, which specifies the statements to initialize a new instance of the class. 3 This corresponds exactly to the block of an instance method with a void return type (§17.5.8).
Paragraph 91 Instance constructors are not inherited. 2 Thus, a class has no instance constructors other than those actually declared in the class. 3 If a class contains no instance constructor declarations, a default instance constructor is automatically provided (§17.10.4).
Paragraph 101 Instance constructors are invoked by object-creation-expressions (§184.108.40.206) and through constructor-initializers.
|Jagger Software Ltd|
|Company # 4070126|
|VAT # 762 5213 42|