0

I am confused. Can anybody help me to understand Difference between IEnumeration<T> instead and List<T>?

sloth
  • 95,484
  • 19
  • 164
  • 210
  • http://stackoverflow.com/questions/3628425/ienumerable-vs-list-what-to-use-how-do-they-work follow this link... – loop Jul 30 '13 at 11:44

1 Answers1

1

You mean IEnumerable<T>. It's the base interface of all collection types like arrays or generic List<T>.

You can for example create a List<int>:

List<int> ints = new List<int>(){ 1,2,3 };

But since it implements IEnumerable<T> you could also declare it in this way:

IEnumerable<int> ints = new List<int>(){ 1,2,3 };

This has the advantage that you cannot modify ints since Remove comes from ICollection<T>.

Tim Schmelter
  • 429,027
  • 67
  • 649
  • 891