Various collections in C # (not to be continued)

Source: Internet
Author: User

Generic collection classes & non-generic collection classes

Generic Collection class: A strongly typed type, mainly refers to checking during code compilation. An object that is not a string type, such as LIST<STRING>, cannot be added to a generic type. Dictionary is also strongly typed.

Non-generic collection classes: are weakly typed, and such collections do not check during compilation. Exceptions that can easily cause type conversions during traversal may involve type conversions. Arraylist,hashtable, wait.

Generic Collection Class:list<t>,dictionary<t>,queue<t>,stack<t>,sortedlist<t>

Non-generic collection class: Arraylist,hashtable,queue,stack,sortedlist

Queue and Stack classes

Queue: FIFO, with Enqueue,dequeue and Peek methods.

Stack: Last-in, first-out, with pop and push two important methods. The push method sends an object to the top of the stack. Pop takes the topmost object out of the stack and deletes it. The Peek method also simply gets the value of the object without deleting the object's value.

***********************************

Queue Testqueue = new Queue ();

for (int i = 0;i<5;i++)

{

Testqueue.enqueue (i)

}

Queue = 0,1,2,3,4

Queue.dequeue ();

Queue = 1,2,3,4

***********************************

Stack teststack = new stack ();

for (int i = 0;i<5;i++)

{

Teststack.push (i)

}

teststack= 4,3,2,1,0

Teststack.pop ();

Queue = 3,2,1,0

Various collections in C # (not to be continued)

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.