我很困惑。IEnumeration<T>
任何人都可以帮助我理解相反和之间的区别List<T>
吗?
user2606468
问问题
1220 次
1 回答
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>
.
于 2013-07-30T11:37:49.567 回答