C # first note --- about list,

Source: Internet
Author: User

C # first note --- about list,

-> List <T> linear set, variable-length Array
-> Add () AddRange () Insert ()
Add an element list. Add ("zhangsan ");
Add a group of elements
String [] temArr = {"Zhang San", "Li Si", "Wang Wu "};
List. AddRange (temArr );
Insert an element list. Insert (1, "Insert element ");
-> Delete Remove (T) RemoveAt (int)
Delete A value: list. Remove ("Zhang San ");
Delete the specified value: list. RemoveAt (0 );
Delete list. RemoveRange (3, 2) of count elements from subscript index)
-> The modification can be modified like an array. // list [9] = '123 ';
-> Query bool Contains (T) IndexOf ()
Find returns the First Matching Element in the entire List.
-> Traverse
Foreach (type temporary variable in set)
{
Use temporary variables for processing
}

-> Simulated queue: first-in-first-out
List. Add ()
List [I] Output
List. ReamoveAt (0) remove existing data
-> Simulated Stack: first-in and later-out (cup and Oreo)
List. Add ()
List [list. Count-1]
List. RemoveAt (list. Count-1) remove existing data

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.