Listing 1
using namespace System; ref struct A { static int Square(int i) { return i * i; } }; ref struct B { int Cube(int i) { return i * i * i; } }; /*1*/ delegate int Del(int value); int main() { /*2*/ Del^ d = gcnew Del(&A::Square); /*3*/ Console::WriteLine("d(10) result = {0}", d(10)); /*4*/ B^ b = gcnew B; /*5*/ d = gcnew Del(b, &B::Cube); /*6*/ Console::WriteLine("d(10) result = {0}", d(10)); }