All asp.net collections

Source: Internet
Author: User

1. When an item is added to the ArrayList, the dynamic change is too small. It is the most suitable for storing frequently changed data.

2. HashTable is a set of data (keys and values ).
HashTable ht = new HashTable ();
Ht ["key value"] = saved information;
For example, ht [0] = "abc"; textbox1.text = ht [0]; // textbox1.text equals to "abc"
Alternatively, ht ["id"] = "abc"; textbox1.text = ht [0]; // textbox1.text equals to "abc"
Same as session usage

3. Stack (first-in-first-out) and Queue (first-in-first-out)
Queue q = new Queue ();
Q. Enqueue (0 );
Q. Enqueue (1 );
TextBox1.Text = q. Dequeue (). ToString (); // The value is 0.

Stack ss = new Stack ();
Ss. Push (0 );
Ss. Push (1 );
TextBox1.Text = ss. Pop (). ToString (); // The value is 1.

4. ListDictionary is suitable for storing a small amount of data, generally less than 10 items.
For example:
String s = "abcdefg ";
ListDictionary ls = new ListDictionary ();
Ls. Add ("wei", s );
TextBox1.Text = ls ["wei"]. ToString ();

5. StringColletion and StringDictionary can only store strings

6. In addition, there are NamevalueCollection sortedList and so on.

The usage is similar. You can guess how to use it according to the prompts.

Note:
ListDIctionary and StringColletion, StringDictionary, NamevalueCollection
In System. Collections. Specialized

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.