Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / docs / ecma334 / 22.2.xml
1 <?xml version="1.0"?>
2 <clause number="22.2" title="Delegate instantiation">
3   <paragraph>An instance of a delegate is created by a <non_terminal where="14.5.10.3">delegate-creation-expression</non_terminal> (<hyperlink>14.5.10.3</hyperlink>). The newly created delegate instance then refers to either: <list><list_item> The static method referenced in the <non_terminal where="14.5.10.3">delegate-creation-expression</non_terminal>, or </list_item><list_item> The target object (which cannot be null) and instance method referenced in the  <non_terminal where="14.5.10.3">delegate-creation-expression</non_terminal>, or </list_item><list_item> Another delegate <example>[Example: For example: <code_example><![CDATA[
4 delegate void D(int x);  
5 class Test  
6 {  
7    public static void M1(int i)  {...}  
8    public void M2(int i)    {...}  
9 }  
10 class Demo  
11 {  
12    static void Main() {   
13       D cd1 = new D(Test.M1); // static method  
14       Test t = new Test();  
15       D cd2 = new D(t.M2);   // instance method  
16       D cd3 = new D(cd2);    // another delegate  
17    }  
18 }  
19 ]]></code_example>end example]</example> </list_item></list></paragraph>
20   <paragraph>Once instantiated, delegate instances always refer to the same target object and method. <note>[Note: Remember, when two delegates are combined, or one is removed from another, a new delegate results with its own invocation list; the invocation lists of the delegates combined or removed remain unchanged. end note]</note> </paragraph>
21 </clause>