Edit

Share via


Compiler Error C3286

'specifier': an iteration variable cannot have any storage-class specifiers

A storage class can't be specified on an iteration variable. For more information, see Storage classes (C++) and for each, in.

Example

The following sample generates C3286, and also shows correct usage.

// C3286.cpp
// compile with: /clr
int main() {
   array<int> ^p = { 1, 2, 3 };
   for each (static int i in p) {}   // C3286
   for each (int j in p) {}   // OK
}