ch chandrakala

ch chandrakala

  • NA
  • 138
  • 6.1k

Explain about IEnumerable..??

Sep 16 2019 4:17 AM
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)