I am confused. Can anybody help me to understand Difference between IEnumeration<T> instead and List<T>?
Asked
Active
Viewed 1,319 times
1 Answers
2
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
- 450,073
- 74
- 686
- 939