Freigeben über


Compilerfehler C3262

Ungültige Array-Indizierung: "#" Dimension(en) wurden für "#"-dimensionales "array type" angegeben

Bemerkungen

Ein Array wurde nicht ordnungsgemäß indiziert. Die Anzahl der Indizes entspricht möglicherweise nicht der Anzahl der Dimensionen im Array.

Example

Im folgenden Beispiel wird C3262 generiert:

// C3262.cpp
// compile with: /clr
#using <mscorlib.dll>
using namespace System;

#define ARRAY_SIZE 2

ref class MyClass {
public:
   int m_i;
};

// returns a multidimensional managed array of a reference type
array<MyClass^, 2>^ Test0() {
   int i, j;
   array< MyClass^, 2 >^ local = new array< MyClass^, 2 >
      (ARRAY_SIZE, ARRAY_SIZE);

   for (i = 0 ; i < ARRAY_SIZE ; i++)
      for (j = 0 ; j < ARRAY_SIZE ; j++) {
         local[i][j] = new MyClass;   // C3262
         // try the following line instead
         // local[i,j] = new MyClass;
         local[i,j] -> m_i = i;
      }

      return local;
}

int main() {
   int i, j;

   array< MyClass^, 2 >^ MyClass0;
   MyClass0 = Test0();
}