ch chandrakala

ch chandrakala

  • 1.7k
  • 113
  • 740

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)