C # Students, all know that a class can only have one inheritance class, but can implement multiple interfaces. This sentence tells us: ienumerable,icollection,ilist,list difference
First I look at IEnumerable:
Summary: //Exposes an enumerator that supports simple iterations on a collection of specified types. //// type parameter: // T: // type of object to enumerate. [Typedependency ("System.szarrayhelper")] public interface ienumerable<out t> : IEnumerable { //Summary: // Returns an enumerator that iterates through the collection. //// return Result: // system.collections.generic.ienumerator<t> that can be used to iterate through the collection. ienumerator<t> GetEnumerator (); }
ienumerable<t> implementation of IEnumerable interface method, that ienumberable do what, in fact, to improve the collection can be looped access. To be blunt is an iteration.
Look again at ICollection:
Summary: // defines methods for manipulating generic collections. //// type parameter: // T: // The type of the element in the collection. [Typedependency ("System.szarrayhelper")] public interface icollection<t>: ienumerable<t , IEnumerable
Originally icollection<t> at the same time inherit Ienumerable<t> and IEnumerable two interfaces, according to my understanding is, ICollection continue their 2 interfaces and extend the method, the function is much stronger.
Turned from the original rifle to a semi automatic rifle.
We continue to look at IList:
Public interface ilist<t>: Icollection<t>, Ienumerable<t>, IEnumerable
By the IList to inherit their three interfaces, no wonder the function so much ah, it should belong to the full automatic rifle
Finally, let's look at list:
public class list<t>: Ilist<t>, Icollection<t>, Ienumerable<t>, IList, ICollection, IEnumerable
This time people look closely, they are all interfaces, only the list is the class, not only to implement their interface, but also extended too many ways for me to use. Wow, almost everything is going to work, it's a laser rifle.
Sort by Function: list<t>-----ilist<t>----icollection<t>----ienumerable<t>
Sort by performance: ienumerable<t>----icollection<t>----ilist<t>----list<t>
rule: The more functions, the lower the performance, so the general situation of MVC view page head using ienumerable<t> more
The pro can be called according to their own needs not array to implement the function, do not blindly use list, thank you!
ASP. Ienumerable,icollection,ilist,list Differences