C # Collection (9) Continuous update

Source: Internet
Author: User

The size of the array is fixed. If the number of elements is dynamic, the collection class is used.

List<t> is a collection class that is equivalent to an array. Other collections: Queues, stacks, lists, dictionaries, and sets.

The. NET Framework 1.0 includes non-generic collection classes, such as ArrayList and HashTable.

Create List
list<intnew list<int> ();

Use the default constructor to create an empty list. If you add an element to the list, the capacity expands to 4 elements. If you add a 5th element, the capacity is 8.

If the capacity of the list changes, the entire collection is reassigned to a new block of memory. To save time, you can create a collection that has a capacity of 10 directly.

list<intnew list<int> (ten;

C # Collection (9) Continuous update

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.