
14 Expressions
14.5 Primary expressions
14.5.10 The new operator
14.5.10.3 Delegate creation expressions
Paragraph 11 A delegate-creation-expression is used to create a new instance of a delegate-type. delegate-creation-expression : new delegate-type ( expression )
Paragraph 21 The argument of a delegate creation expression must be a method group (§14.1) or a value of a delegate-type. 2 If the argument is a method group, it identifies the method and, for an instance method, the object for which to create a delegate. 3 If the argument is a value of a delegate-type, it identifies a delegate instance of which to create a copy.
Paragraph 31 The compile-time processing of a delegate-creation-expression of the form new D(E), where D is a delegate-type and E is an expression, consists of the following steps:
delegate double DoubleFunc(double x);
class A
{
DoubleFunc f = new DoubleFunc(Square);
static float Square(float x) {
return x * x;
}
static double Square(double x) {
return x * x;
}
}
the A.f field is initialized with a delegate that refers to the second Square method because that method exactly matches the formal parameter list and return type of DoubleFunc. Had the second Square method not been present, a compile-time error would have occurred. end example]
| |
| Jagger Software Ltd | |
| Company # 4070126 | |
| VAT # 762 5213 42 |