Using System;
Using System.Collections;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Namespace ConsoleApplication2
{
Class Program
{
static void Main (string[] args)
{
int[] arr1 = new int[2] {n};
int[,] arr2 = new int[2, 3] {
{0,1,2},
{2,3,4}
};
Console.WriteLine (arr2[1,1]);
ArrayList
ArrayList alt = new ArrayList ();
Alt. ADD ("123");
Alt. ADD (123);
Alt. ADD (TRUE);
BOOL Iscontain = alt. Contains ("1");
Alt. Clear ();
/*alt. Insert (0, "abc") */
;
Console.WriteLine (Iscontain);
for (int i = 0; i < Alt. Count; i++)
{
Console.WriteLine (Alt[i]. ToString () + "" + alt[i]. GetType (). ToString ());
}
foreach (var x in Alt)
{
Console.WriteLine (x.tostring () + "" + X.gettype (). ToString ());
}
Generic collection List
list<string> str_list = new list<string> ();
Str_list. ADD ("a");
Str_list. ADD ("B");
Str_list. ADD ("C");
Str_list. ADD ("D");
foreach (string x in Str_list)
{
Console.WriteLine (x);
}
Hash table Hashtable
Hashtable ht = new Hashtable ();
Ht. ADD ("1", "a");
Ht. ADD (2, "B");
Ht. ADD (3, false);
Ht. ADD ("x", 3.14);
Console.WriteLine (Ht[2]);
foreach (Var x in HT. Keys)
{
Console.WriteLine (Ht[x]);
}
Dictionary table Dictionary
dictionary<string, int> dic = new dictionary<string, int> ();
Dic. ADD ("A", 3);
Dic. ADD ("B", 4);
Dic. ADD ("C", 5);
Dic. ADD ("D", 6);
Dic. ADD ("E", 7);
foreach (Var x in dic. Keys)
{
Console.WriteLine (x);
}
Queues Queue
Queue que = new queue ();
Que. Enqueue ("Zhang San");
Que. Enqueue ("John Doe");
Que. Enqueue ("Harry");
Que. Enqueue ("Zhao Liu");
Console.WriteLine ("Now the length is" + Que. Count);
Console.WriteLine (Que. Dequeue ());
Console.WriteLine ("Now the length is" + Que. Count);
Stack stacks
Stack st = new stack ();
St. Push ("a");
St. Push ("B");
St. Push ("C");
St. Push ("D");
Console.WriteLine (St. Count);
Console.WriteLine (St. Pop ());
Console.WriteLine (St. Count);
Console.ReadLine ();
int[] arr1 = new Int[2] {1, 2};
int[,] arr2 = new int[2, 3]{
{0,1,2},{2,3,4}
};
Console.WriteLine (arr2[1, 1]);
ArrayList characteristics do not need to limit the length, do not need to specify the type, disadvantage: The key value can only be 0,1,2,3 to the rear:
ArrayList alt = new ArrayList ();
Alt. ADD ("123");
Alt. ADD (123);
Alt. ADD (TRUE);
Alt. Remove (123); Remove clear from it is the meaning of all empty
BOOL Iscontain=alt. Contains ("123"); See if it contains "123", if any, it will show "true", if not, it will display false;
Alt. Clear (); Clear all:
Alt. Insert (0, "abc"); It means inserting a string "123" into a 0 position;
Console.WriteLine (ALT);
for (int i = 0; i < Alt. count;i++) {
Console.WriteLine (Alt[i]. ToString () + "" +alt[i]. GetType (). ToString ());
}
var type is a universal type
foreach (var x in Alt) {
Console.WriteLine (x.tostring () + "" +alt[i]. GetType (). ToString)
}
Generic collection list needs to specify the type, does not need to specify the length also does not have the stipulation key value also starts from 0,1,2,3 the platoon
list<string> str_list = new list<string> ();
Str_list. ADD ("a");
Str_list. ADD ("B");
Str_list. ADD ("C");
Str_list. ADD ("D");
foreach (string x in Str_list) {
Console.WriteLine (x);
}
Hash table Hashtable good in the concept of order
Hashtable ht = new Hashtable ();
Ht. ADD ("1", "a");
Ht. ADD (2, "B");
Ht. ADD (3, false);
Ht. ADD ("x", 3.14);
Console.WriteLine (Ht[2]);
foreach (Var x in HT. Values) {
Console.WriteLine (x);
}
foreach (Var x in HT. Keys)
{
Console.WriteLine (x); Take all the values
Console.WriteLine (Ht[x]);
}
Dictionary table Dictionary
dictionary<string, int> dic = new dictionary<string, int> ();
Dic. ADD ("A", 3);
Dic. ADD ("B", 4); The preceding key is the value
Dic. ADD ("C", 5);
Dic. ADD ("D", 6);
Dic. ADD ("E", 7);
Dic. Add ("F", 8);
foreach (Var x in dic. Keys) {
Console.WriteLine (x);
}
Queuing queue FIFO
Queue que = new queue ();
Que. Enqueue ("Zhang San");
Que. Enqueue ("John Doe");
Que. Enqueue ("Harry");
Que. Enqueue ("Zhao Liu");
Console.WriteLine ("Now the length is" + Que. Count);
Console.WriteLine (Que. Dequeue ()); The Dequeue () function is used to remove the first function in the specified queue for each matching element and to execute the removed function.
Console.WriteLine ("Current Length" + Que. Count);
Stacks Stack advanced after
Stack st = new stack ();
St. Push ("a");
St. Push ("B");
St. Push ("C");
St. Push ("D");
St. Push ("E");
Console.WriteLine (St. Count);
Console.WriteLine (St. Pop ());
Console.WriteLine (St. Count);
Console.ReadLine ();
}
}
}
Arrays and collections