2
Answers

IEnumerable

Maha

Maha

9y
654
1
In this example IEnumerable interface is given a type 'int'. How to explain this situation?. Problem is highlighted.

using System;
using System.Collections.Generic;

class Program
{
static void Main()
{
List<int> oyears = new List<int>();
oyears.Add(1990);
oyears.Add(1991);
oyears.Add(1992);
oyears.Add(1993);
oyears.Add(2001);
oyears.Add(2002);
oyears.Add(2003);

IEnumerable<int> ienum = (IEnumerable<int>)oyears;

foreach (int i in ienum)
{
Console.WriteLine(i);
}


Console.ReadKey();
}
}

Answers (2)