foreach statement cannot operate on variables of type 'type1' because 'type2' does not contain a definition for 'member', or it is inaccessible
A data type (type1) does not contain a member that allows foreach to iterate through type2.
The following sample generates CS1579:
using System; public class C1 { public int GetEnumerator () { return 0; } } public class MainClass { public static void Main () { C1 c1 = new C1(); foreach (int x in c1) { // CS1579 } } }