C # collections and Special Collections

Source: Internet
Author: User

First, ArrayList collection

. Add () Adds an object to the element that is actually contained in the Arraylidt

. Insert () Inserts an element into the ArrayList at the specified index. can be inserted at any location

. Remove () Removes the first occurrence of a specific object from the ArrayList

. RemoveAt () Removes the element at the specified index of the ArrayList

. Count gets the elements that are actually contained in the ArrayList

. Contians () determines whether an element is in ArrayList

. IndexOf ()

. LastIndexOf ()

. Sort () is overloaded, sorting the elements in ArrayList or part of it, ascending

If you need to sort in descending order, after auto-arranging, the reverse instruction is awakened to the whole set. Reverse ();

Case:

1. Remove data, data index, sort, reverse order,

2, enter the number of people, enter the score of each person, the average, sorted and into descending order

Second, Stack collection

Stack is not indexed.

Advanced post-out, LIFO, an assignment, one value, in order.

. Count goes to the number of elements in the collection

. push () pushes the element one by one into the collection

Pop () pops a collection of elements

. Clear () empties the collection

Case:

1, only to view, not remove, and calculate the collection has several elements

Third, queue collection

FIFO, an assignment of one to one value, in order. (no index)

. Count takes the number of elements in the collection

. Enqueue into the queue collection

. Dequeue Out Queue Collection

. Clear to empty the collection

1. Calculate how many elements are in a set

C # collections and Special Collections

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.