ECMA-334 C# Language Specification22.2: Delegate instantiation |
An instance of a delegate is created by a delegate-creation-expression (14.5.10.3). The newly created delegate instance then refers to either:
delegate-creation-expression, or delegate-creation-expression, or
delegate void D(int x);
class Test
{
public static void M1(int i) {...}
public void M2(int i) {...}
}
class Demo
{
static void Main() {
D cd1 = new D(Test.M1); // static method
Test t = new Test();
D cd2 = new D(t.M2); // instance method
D cd3 = new D(cd2); // another delegate
}
}
|
Once instantiated, delegate instances always refer to the same target object and method.