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

Source: Internet
Author: User
Differences between. NET 2.0 generic collection classes and. NET 1.1 Collection classes (1)

3. Interfaces
The icollection with the largest changes in the interface <t>. In 1.1, icollection is a read-only version, and there is no way for you to modify the data in the set, however, the method for modifying data and the isreadonly attribute are added to the generic icollection <t>. I am sorry that I have not found the generic read-only version of icollection.

Icollection <t> although data can be modified, it does not support indexing, so it defines the ilist <t> interface, it inherits from icollection <t> and provides the digital retrieval function.

In terms of compatibility with the collection interfaces of earlier versions, ienumerable <t> supports ienumerable, icollection <t> does not support icollection, and ilist <t> does not support ilist.

System. collections. generic. idictionary <tkey, tvalue> is not much different from the old dictionary. At the inheritance level of the interface, the original idictionary is inherited from icollection, it is still the corresponding generic version of icollection <t>, but because icollection <t> adds the data modification function, it brings some trouble, because the dictionary requires the add method to pass in the key and value parameters, while the icollection add can only have one parameter, the icollection <t> is restricted to: icollection <keyvaluepair <tkey, tvalue> to provide two parameters.

The dictionary interface also adds trygetvalue (tkey, tvalue). This method is mainly used to improve performance. If you want to obtain a key location safely, you must use containskey (tkey) search for existence first, and then use this to search. In this case, there are two retrieval processes. The current trygetvalue will only be retrieved once.

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.