Array, array list ArrayList and list, Dictionary, SortedList, Hashtable

Source: Internet
Author: User

usingSystem;usingSystem.Collections.Generic;//header file for the value chain listusingSystem.Linq;usingSystem.Text;usingSystem.Collections;//header file for the value chain listnamespaceconsoleapplication1{classProgram {Static voidMain (string[] args) {            int[] Nmbers =New int[5]; string[,] names =New string[5,4]; byte[] scores =New byte[5][];  for(inti =0; I < scores. Length; i++) {Scores[i]=New byte[i +3]; }             for(inti =0; I < scores. Length; i++) {Console.WriteLine ("Length of Row{0} is {1}", I, scores[i].                Length); int[] Nmbers2 =New int[5] {1,2,3,4,5 }; string[,] name2 = {{"g","k"}, {"DD","Eee" } }; intA =nmbers2.               Length; //console.readline ();} ArrayList Al=NewArrayList ();//Value Chain ListAl. ADD (5); Al. ADD ( -); Al. Remove (5); Al. ADD ("DFDFDFDFDF"); foreach(varAinchal)            {Console.WriteLine (a); } Console.WriteLine (al[0]); List<int> intlist =Newlist<int> ();//Value Chain ListIntlist.add ( -);//IncreaseIntlist.addrange (New int[]{501,502});//IncreaseConsole.WriteLine (Intlist.contains ( $));//whether a value existsConsole.WriteLine (Intlist.indexof (501));//find a worthwhile location for the first timeIntlist.remove (501);//DeleteIntlist.insert (1,1001);//InsertHashtable HT=NewHashtable ();//hash table type does not specifyht. ADD (" First","Jike");//Key value valuesHt. ADD ("Second","Xueyuan"); Console.WriteLine (ht[ About]);//There is no one key value returned as nulldictionary<string,string> d =Newdictionary<string,string> ();//type specifies that a strongly typed thread is unsafe. Thread safety is concurrentdictionary multi-dictionaryD.add (" First","Jike"); //is not a key value, an exception is thrownConsole.WriteLine (ht["Second"]); SortedList<int,int> S1 =Newsortedlist<int,int> ();//sort by key value regardless of value size, increment orderS1. ADD (5, the); S1. ADD (2,1025); S1. ADD (4,1055); S1. ADD (6,1015); S1. ADD (7,1005); S1. ADD (Wuyi,1035); S1. ADD ( *,1095); foreach(varSleinchS1) {Console.WriteLine (SLE. Value);//can be a key value and a value            }            //stack stacks, queue queuesConsole.ReadLine (); }    }}

Array, array list ArrayList and list, Dictionary, SortedList, Hashtable

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.