IENumerable,IList,ICollection之间有什么不同 [英] what is diffrent between IENumerable,IList,ICollection
问题描述
hi
什么是IENumerable,IList,ICollection或IENumerable< t>,IList< t>,ICollection< t> ?
IENumerable,IList,ICollection或IENumerable< t>,IList< t>,ICollection< t>?
之间的差异
我何时何地可以使用IENumerable或IList或ICollection或IENumerable< t>,IList< t>,ICollection< t>?
我如何使用IENumerable或IList或ICollection或IENumerable< t>,IList< t>,ICollection< t>?
请完整解释
储罐
hi
what is IENumerable,IList,ICollection or IENumerable<t>,IList<t>,ICollection<t> ?
what is diffrent between IENumerable,IList,ICollection or IENumerable<t>,IList<t>,ICollection<t>?
when and where can i use IENumerable or IList or ICollection or IENumerable<t>,IList<t>,ICollection<t>?
How can i use IENumerable or IList or ICollection or IENumerable<t>,IList<t>,ICollection<t>?
Please fully explain
tanks
推荐答案
请参阅以下链接。它很好地解释了每个提到的集合。
何时使用IEnumerable,ICollection,IList和List [ ^ ]
谢谢
Please see the below link. It explained each of the mentioned collection very well.
When to use IEnumerable, ICollection, IList and List[^]
Thanks
请记住,所有这些I ---实体都是接口,您可以将其视为抽象模式...蓝图,如果您愿意......和一个契约,一组对从它们继承的对象的要求:承诺实现某些功能。
所以,一个List< SomeType>是一个IList的化身,因此,它提供了一套特定的设施,比如索引,它是可枚举的...你可以用'foreach等遍历它。事实上,IList继承自IEnumerable和ICollection。所以,List< SomeType>提供了所有三个接口的功能。
有一篇很好的CodeProject文章,IEnumerable,ICollection,IList和IDictionary之间的区别,总结了这些接口,以及它们的实现是:[ ^ ]。
这里有一些很好的讨论:[ ^ ]。
Keep in mind that all these I--- entities are Interfaces, which you can think of as both an abstract schema ... a blue-print, if you will ... and a "contract," a set of requirements for objects that inherit from them: a promise to implement certain functionality.
So, a List<SomeType> is an "incarnation" of an IList, and, so, it provides a certain set of facilities, like indexing, it is enumerable ... you can "traverse" it with 'foreach, etc. In fact, IList inherits from both IEnumerable, and ICollection. So, a List<SomeType> provides the functionality of all three Interfaces.
There is a good CodeProject article, "Difference between IEnumerable, ICollection, IList, and IDictionary," summarizing what these Interfaces, and their implementations, are: [^].
There are some excellent discussions of this here: [^].
这篇关于IENumerable,IList,ICollection之间有什么不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!