Nóta
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as shíniú isteach nó eolairí a athrú.
Teastaíonn údarú chun rochtain a fháil ar an leathanach seo. Is féidir leat triail a bhaint as eolairí a athrú.
the type 'type' (return type of GetEnumerator) must have a suitable public MoveNext member function and public Current property
Remarks
User-defined collection classes must contain definitions for MoveNext and Current.
For more information, see for each, in.
Example
The following example generates C3287.
// C3287.cpp
// compile with: /clr
using namespace System;
ref struct R {
bool MoveNext() {
return true;
}
property Object^ Current {
Object^ get() {
Object ^ o = gcnew Object;
return o;
}
}
};
ref struct R2 {
R ^GetEnumerator() {
R^ r = gcnew R;
return r;
}
};
ref struct T {};
ref struct T2 {
T ^GetEnumerator() {
T^ t = gcnew T;
return t;
}
};
int main() {
for each (int i in gcnew T2) {} // C3287
for each (int i in gcnew R2) {} // OK
}