編譯器錯誤 C2217
'attribute1' 需要 'attribute2'
第一個函式屬性需要第二個屬性。
範例
如果您嘗試將委派繫結至接受可變引數數目的 CLR 函式,可能會發生 C2217。 如果函式也有 param 陣列多載,請改用它。 下列範例會產生 C2217。
// C2217.cpp
// compile with: /clr
using namespace System;
delegate void MyDel(String^, Object^, Object^, ...); // C2217
delegate void MyDel2(String ^, array<Object ^> ^); // OK
int main() {
MyDel2^ wl = gcnew MyDel2(Console::WriteLine);
array<Object ^ > ^ x = gcnew array<Object ^>(2);
x[0] = safe_cast<Object^>(0);
x[1] = safe_cast<Object^>(1);
// wl("{0}, {1}", 0, 1);
wl("{0}, {1}", x);
}