It clearly tells you that the object
Model
cannot be used as a set of object for using in
foreach
. This is simple: the type of such object should support
System.Collections.IEnumerable
:
https://msdn.microsoft.com/en-us/library/system.collections.ienumerable%28v=vs.110%29.aspx[
^].
Pay attention: IEnumerable
, not IEnumerator
! You would need to implement
IEnumerator
by the enumerator, the object
returned by
System.Collections.IEnumerable.GetEnumerator
.
Yes, collections generally implement
System.Collections.IEnumerable
. When in doubt, look at the MSDN help page if the type in question and check it up; this detail is always shown. You did not show the type of your
Model
object, but it is certainly not a collection and is not derived from any collection type, but probably one of its members is of collection type, so, as in most cases, you probably still won't need to implement this interface.
—SA