Collection
Can be seen as an array
Create an array of length 10
Array length is 10, to insert new data, you have to re-create the array sort
Fixed length, not too flexible
Use collections to easily solve these problems
You can see the set as "variable-length, array with many methods"
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Collections;namespacethe various methods of _07arraylist {classProgram {Static voidMain (string[] args) {ArrayList list=NewArrayList (); //Add a single elementList. ADD (true); List. ADD (1); List. ADD ("Zhang San"); //adding a collection elementList. AddRange (New int[] {1,2,3,4,5,6,7,8,9 }); //list. AddRange (list); //list. Clear (); Clear all elements//list. Remove (true); Deletes a single element write who will delete who//list. RemoveAt (0); Delete element according to subscript//list. RemoveRange (0, 3); Remove a range of elements according to the subscript//list. Sort ();//Ascending order//list. Reverse (); Reverse//list. Insert (1, "inserted"); Inserts an element at the specified position//list. Insertrange (0, new string[] {"Zhang San", "John Doe"}); Inserts a collection at the specified location//bool B = list. Contains (1); determine if a specified element is includedList. ADD ("Geng Shiwei"); if(!list. Contains ("Geng Shiwei") ) {list. ADD ("Geng Shiwei"); } Else{Console.WriteLine ("There's already this dick."); } for(inti =0; I < list. Count; i++) {Console.WriteLine (list[i]); } console.readkey (); } }}
C # Fundamentals [9] ArrayList set (i)