ARRAYLIST Collection Class
The Remove method removes an element from ArrayList, ArrayList reorder, remove (value), RemoveAt (index)
Add (value) adds values to the ArrayList tail
Insert (PARA1,PARA2) The first parameter is the position to be joined (where the Para2 is added), and the second parameter is the value to be inserted, if number={1,2,3,4,5}
QUEUE Collection Class
First in, first out mechanism (FIFO) queued at queue tail (Enqueue), from Queue Head (Dequeue)
Enqueue () method
Dequeue () method
STACK Collection Class
The Stack class is the post-first-out mechanism (lifo,list-in, first-out), and the new member is in the first line
Push () method into the stack
Pop () method out of stack
Hashtable Collection Class
A hash table provides a mapping in which each key corresponds to a value, and if an existing key is specified, the value can only be indexed by square brackets.
Add only adds [Key,value] that does not already exist, cannot add only the KEY value, does not establish a mapping
1 Hashtable ages = new Hashtable (); 2 ages. ADD ("Wangxiao"), 3 ages["Wangxiao"]=15;
A dictionaryentry (struct type) is returned when a hash table is traversed using foreach, and the contents of the Hashtable can be accessed through the Key/value property
foreach (dictionaryentry element in ages) { String name = (string) element. Key;int age = (int) element. Value; Console.WriteLine ("Name: {0} Age: {1}", name,age); Console.ReadLine (); }
SortedList Collection Class
The Sortlist class is similar to a hash table, except that sortlist is always sorted by key, and the data is re-sorted after the change.
1 SortedList ages = new SortedList (); 2 ages. ADD ("James", 22); 3 ages. ADD ("Edward", 25); 4 ages. ADD ("Lucy", +); 5 foreach (dictionaryentry element in ages) 6 {7 string name = (string) element. Key; 8 int age = (int) element. Value; 9 Console.WriteLine ("Name: {0} Age: {1}", name, age); console.readline ();
Collection initialization
Add value when a simple collection class can be named directly
Arrylist numbers=new ArrayList () {1,2,3,4,5,6};
For hash tables and SortedList collections to declare Key/value
Hashtable ages=new Hashtable () {"James", 22},{"Edward", 25},{"Lucy", 20}};