Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C2107

Error Message

illegal index, indirection not allowed

A subscript is applied to an expression that does not evaluate to a pointer.


C2107 can occur if you incorrectly use the this pointer of a value type to access the type's default indexer. For more information, see Semantics of the this Pointer in Value and Reference Types.

The following sample generates C2107.

// C2107.cpp
// compile with: /clr
using namespace System;

value struct B {
   property String ^ default[String ^] {
      String ^ get(String ^ data) {
         return "abc";
   void Test() {
      Console::WriteLine("{0}", this["aa"]);   // C2107
      Console::WriteLine("{0}", this->default["aa"]);   // OK

int main() {
   B ^ myb = gcnew B();

Community Additions

© 2015 Microsoft