Tag Archives: difference between ienumerable and enumerable

Difference between IEnumerator and IEnumerable

IEnumerable An enumerable class implements the IEnumerable interface. The IEnumerable interface has only one method GetEnumerator, which returns an IEnumerator interface. public IEnumerator GetEnumerator(); Example:- class Program { static void Main() { List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); List<int>.Enumerator e = list.GetEnumerator(); Write(e); } static void Write(IEnumerator<int> e) { while (e.MoveNext())… Read More »