List<Animals> li = new List<Animals>();
Animals n = new Animals();
n.Cat = 1;
n.Dog = 2;
n.tiger = 3;
li.Add(n);
Animals n1 = new Animals();
n1.Cat = 2;
n1.Dog = 2;
n1.tiger = 3;
li.Add(n1);
IEnumerable<Animals> test= li;
foreach (var item in test)
{
Console.WriteLine(item.Cat);
}
foreach (var item in li)
{
Console.WriteLine(item.Cat);
}
Console.Read();
What is the difference between Ienumerable and list.List implements the interface Ienumerable.so it Includes all methods of IEnumerable.
Where should I use IEnumerable<> And List<> respectively.
Please Explain me the difference with an example.