Listing 3
delegate void D1(); delegate void D2(); public struct A { static void M1() { /* ... */ } static void M2() { /* ... */ } }; void X(D1^ m) { /* ... */ } void Y(D2^ n) { /* ... */ } int main() { D1^ d1; /*1*/ d1 = gcnew D1(&A::M1); // compatible /*2*/ d1 = gcnew D1(&A::M2); // compatible D2^ d2; /*3*/ d2 = gcnew D2(&A::M1); // compatible /*4*/ d2 = gcnew D2(&A::M2); // compatible /*5*/ d1 = d2; // incompatible /*6*/ d2 = d1; // incompatible /*7*/ X(d1); // compatible /*8*/ X(d2); // incompatible /*9*/ Y(d1); // incompatible /*10*/ Y(d2); // compatible }