This error can occur if you incorrectly use the this pointer of a value type to access the type's default indexer. Ex:
// compile with: /clr
using namespace System;
value struct B {
property Double default[Double] {
Double get(Double data) {
return data*data;
}
}
void Test() {
Console::WriteLine("{0}", this[3.3]); // C2108
}
};
int main() {
B ^ myb = gcnew B();
myb->Test();
}
Possible resolution:
void Test() {
Console::WriteLine("{0}", this->default[3.3]); // OK
}
This article is a derivative work based on Compiler Error C2108 which is provided by MSDN Community Content - Visual C++.