Error del compilador C3915
"type" no tiene una propiedad indexada predeterminada (indizador de clase)
Un tipo no tiene una propiedad indexada predeterminada.
Para obtener más información, consulta property.
Ejemplos
El ejemplo siguiente genera el error C3915.
// C3915.cpp
// compile with: /clr
ref class X {
public:
// uncomment property to resolve this C3915
// property int default[]
// {
// int get(int i)
// {
// return 863;
// }
// }
};
int main() {
X^ x = new X;
System::Console::WriteLine(x[1]); // C3915
}
El error C3915 también puede producirse si intenta consumir un indizador predeterminado en el mismo compilador en el que se definió con DefaultMemberAttribute.
El ejemplo siguiente genera el error C3915.
// C3915_b.cpp
// compile with: /clr
using namespace System;
[Reflection::DefaultMember("XXX")]
ref struct A {
property Double XXX[Double] {
Double get(Double data) {
return data*data;
}
}
};
ref struct B {
property Double default[Double] {
Double get(Double data) {
return data*data;
}
}
};
int main() {
A ^ mya = gcnew A();
Console::WriteLine("{0}", mya[3]); // C3915
B ^ myb = gcnew B();
Console::WriteLine("{0}", myb[3]); // OK
}