3
Answers

Explain about IEnumerable..??

Please explain about IEnumerable in easy way and why we need?
 
List<int> Yrs = new List<int>();
Yrs.Add(1992);
Yrs.Add(1993);
Yrs.Add(1994);
Yrs.Add(1996);
Yrs.Add(1997);
Yrs.Add(1998);
// IEnumerable<int> ienum = (IEnumerable<int>)Yrs;
foreach (int i in Yrs)
{
Console.WriteLine(i);
}
 
With out IEnumerable also foreach loop works what is the need?
Answers (3)