Errore del compilatore C3459
'attribute': attributo consentito solo su indicizzatore di classe (proprietà indicizzata predefinita)
Un attributo progettato per essere applicato a una proprietà dell'indicizzatore di classe è stato usato in modo errato.
Per altre informazioni, vedere Procedura: Usare le proprietà in C++/CLI.
Esempio
L'esempio seguente genera l'errore C3459.
// C3459.cpp
// compile with: /clr /c
public ref class MyString {
public:
[System::Runtime::CompilerServices::IndexerName("Chars")] // C3459
property int Prop;
};
// OK
public ref class MyString2 {
array<int>^ MyArr;
public:
MyString2() {
MyArr = gcnew array<int>(5);
}
[System::Runtime::CompilerServices::IndexerName("Chars")] // OK
property int default[int] {
int get(int index) {
return MyArr[index];
}
void set(int index, int value) {
MyArr[index] = value;
}
}
};