. The collection in net

Source: Internet
Author: User

Collection namespaces:

Using. System.Collections; (non-generic collection)

Using. System.Collections.Genneric (Generic collection)

Common collections

1. "Array-like" collection:ArrayList, list<t>

2. "Key-value pairs" collection ("Hash Table" collection):hashitable, dictionry<k,v>

3. "Stack" collection: Stack, stack<t> (LIFO) last Infirst out

4. Queue collection: Queue, queue<t> (FIFO) first in first out

A collection of blue collections that are used primarily.

ArrayList Count and Capcity one is the number of elements, a number of capacity, when stored in an element count=1 capacity of 4, save the second time count=2 capacity=4

When deposited in the 5th, Count=5 Capacity=8, because the capacity initial capacity of 4, when the capacity reached 4 times doubled.

Array loop traversal with length and count plus indexer when set

Inserts an element into the specified position

    adding elements

Arrlist. Insert (0, "the Emperor");

    add Element-

Arrlist.addrange (); The method parameter is the ICollection interface. In other words, this parameter can pass the subclass of the integrated ICollection interface, which has many subclasses, which are basically collections and arrays

Arrlist.addrange (new int []{1,2,4,5,87,93,5});

    Delete Element

Arrlist. Removeat (0);

Arrlist. Removeatrange ();

    

  

    

. The collection in net

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.