Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
invalid array indexing: '#' dimension(s) specified for '#'-dimensional 'array type'
Remarks
An array was improperly subscripted. The number of indices may not match the number of dimensions in the array.
Example
The following example generates C3262:
// 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();
}