C # differences between ienumerable <t>, ienumerator <t>, list <t>, arraylist, and [] Arrays

Source: Internet
Author: User

List <t> is the generic type of arraylist, the Data Type in arraylist is object, and the Data Type in list <t> is specific.

Arraylist is similar to a vector and can store different data types in an array (converted to an object ).

Generally, use list <t> as much as possible, because arraylist access must be converted once (packed or unpacked ).

The [] type array is similar to the list <t>. The difference is that [] is fixed length, while list <t> is a variable length array.

Icollection mainly targets static sets; ilist mainly targets dynamic Sets
Ienumerable <t> inherited from ienumerable
Icollection <t> inherited from ienumerable <t>
Ilist <t> inherited from icollection <t>
Ienumerable Interface

The set that implements the ienumerable interface indicates that this set can provide an enumerator (enumerator) object and supports the current traversal set. The ienumerable interface has only one member getenumerator () method.

The ilist interface and the arraylist class are used to implement dynamic arrays. arraylist is an implementation of ilist.

Ienumerable indicates that the object is a collection of uncertain types and supports simple iteration. It doesn't matter if it is fixed length...

Ienumerable <t> indicates that the object is a set of the specified type and supports simple iteration. It doesn't matter whether the set length is...

Icollection is a derived interface of the ienumerable interface. It indicates that the object is a set of uncertain types and supports simple iteration. It also defines the set size, enumeration number, and synchronization method, the size here refers to whether it can be fixed or not long...

Ilist is a derived interface of icollection and ienumerable. It indicates that the object is a set of uncertain types and supports simple iteration. It also defines the set size, enumeration number, and synchronization method, it can also be accessed separately based on the index. The size here can be fixed length or variable length...

The arraylist class is the implementation of the ilist interface, indicating that the object is an array of uncertain type sizes that can be dynamically increased as needed...

The list <t> class is the implementation of the ilist <t> interface. It is a generic equivalent class of the arraylist class and enhances its functionality, indicates that the object is a list of strong types of objects that can be accessed through indexes... in. NET 2.0 or above can completely replace arraylist, that is, arraylist has been eliminated, and dynamic arrays and linked lists are essentially different... in. NET 2.0 and above have two-way linked list lists <t> generic classes, which are also inherited from icollection <t>, ienumerable <t>, icollection, ienumerable...

A set that can be traversed using foreach must inherit the ienumberable (or ienumerable <t> generic interface) interface.

The ienumberable interface has only one method:
Ienumerator getenumberator () {}// returns an ienumberator-type object, which implements the system. collection. ienumerator interface.

 

C # differences between ienumerable <t>, ienumerator <t>, list <t>, arraylist, and [] Arrays

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.