disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 17.10.6.xml
blob76472a9d9a79b2ec72ade74bdee13fa35e2a47b9
1 <?xml version="1.0"?>
2 <clause number="17.10.6" title="Optional instance constructor parameters">
3   <paragraph>
4     <note>[Note: The this(...) form of constructor initializer is commonly used in conjunction with overloading to implement optional instance constructor parameters. In the example <code_example><![CDATA[
5 class Text  
6 {  
7    public Text(): this(0, 0, null) {}  
8    public Text(int x, int y): this(x, y, null) {}  
9    public Text(int x, int y, string s) {  
10       // Actual constructor implementation  
11    }  
12 }  
13 ]]></code_example>the first two instance constructors merely provide the default values for the missing arguments. Both use a this(...) constructor initializer to invoke the third instance constructor, which actually does the work of initializing the new instance. The effect is that of optional constructor parameters: <code_example><![CDATA[
14 Text t1 = new Text();          // Same as Text(0, 0, null)  
15 Text t2 = new Text(5, 10);       // Same as Text(5, 10, null)  
16 Text t3 = new Text(5, 20, "Hello");  
17 ]]></code_example>end note]</note>
18   </paragraph>
19 </clause>