Compiler Error C3285
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3285.
for each statement cannot operate on variables of type 'type'
The for each statement repeats a group of embedded statements for each element in an array or an object collection.
See for each, in for more information.
The following sample generates C3285.
// C3285.cpp
// compile with: /clr
int main() {
for each (int i in 0) {} // C3285
array<int> ^p = { 1, 2, 3 };
for each (int j in p) {} // OK
}
Show: