Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.04 KB

compiler-error-c2108.md

File metadata and controls

44 lines (35 loc) · 1.04 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Error C2108
Compiler Error C2108
06/03/2022
C2108
C2108
c84f0b47-5e2c-47d2-8edb-427a40e17c36

Compiler Error C2108

subscript is not of integral type

Remarks

The array subscript is a non-integer expression.

Example

C2108 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.

The following sample generates C2108.

// C2108.cpp
// 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
      Console::WriteLine("{0}", this->default[3.3]);   // OK
   }
};

int main() {
   B ^ myb = gcnew B();
   myb->Test();
}