Differences between. NET 2.0 generic collection classes and. NET 1.1 Collection classes (1)

Source: Internet
Author: User

This article aims to explain the differences between. NET 2.0 generic collection classes and. NET 1.1 Collection classes, rather than introducing the advantages or use of generic. This articleArticleSuppose you have simply used generics for programming.
This article uses. NET 2.0 2.0.50215.44, which may be different from the official version.

1. namespace
In 1.1, the set namespace includes:

System. Collections Common dynamic array arraylist, Dictionary base class dictionarybase, set base class collection, and others.
System. Collections. Specialized A typical strong collection class that uses a string as the key to retrieve the nameobjectcollectionbase. It can store the namevaluecollection of strings.

In. NET 2.0, besides the previous namespaces, the following namespaces are added:

System. Collections. Generic Core generic set implementation, including dynamic array list and dictionary;
System. Collections. objectmodel Keyedcollection, a collection object and a dictionary that are common in external object models;

In. NET 1.1, the queue and stack implemented by mscorlib. dll correspond to the generic implementation of. NET 2.0 and are moved to system. dll. In addition ,. NET 2.0's generic implementation is not exactly the same as the original one-to-one implementation. It combines the classes with previous repeated functions into a generic implementation and adds some new classes that were not previously created, for example, upload list.

2. system. Collections. Generic. List <t>
List <t> is the original generic Implementation of arraylist, and is the most basic, best-performing, and most powerful "dynamic array". It is recommended to useProgramBut it is not recommended to expose it directly to external programs because there are too many "portals. To expose your collection, see use collection <t>. In fact, many generic collection classes use a list, such as collection.

List <t> implements the sorting function. The sort method can be used to sort various tasks. Therefore, it does not need to implement sortedlist in 1.1.

List <t> Removes the support for the original list functions and provides some interesting functions, such:
List <t>. foreach (system. Action <t>) facilitates a simple loop, see: http://notgartner.com/posts/1510.aspx
System. Collections. Generic. List <t>. toarray () can directly return a strongly-typed array, so you don't have to create an array first, copy it, and then return it.

List <t> implements generic ilist <t> and non-generic ilist interfaces.

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.