Compartir a través de


Error del compilador C2217

'atritubo1' requiere 'atributo2'

El primer atributo de función requiere el segundo atributo.

Ejemplo

Se puede producir C2217 si intenta enlazar un delegado a una función CLR que toma un número variable de argumentos. Si la función también tiene una sobrecarga de matriz de parámetro, utilícela en su lugar. El ejemplo siguiente genera 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);
}