编译器错误 C3354

“%$I”:该函数用于创建不能有返回类型“type”的委托

以下类型作为 delegate的返回类型无效:

  • 指向函数的指针

  • 指向成员的指针

  • 指向成员函数的指针

  • 对函数的引用

  • 对成员函数的引用

以下示例生成 C3354:

// C3354_2.cpp
// compile with: /clr /c
using namespace System;
typedef void ( *VoidPfn )();

delegate VoidPfn func(); // C3354
// try the following line instead
// delegate  void func();