Collections and Arrays

Source: Internet
Author: User

Two-dimensional arrays:

One-dimensional array Beans

Two-dimensional array Form

Defined:

One-dimensional arrays:

Data type [] array variable name =new data type [ data length ];

Data type [] array variable name =new data type [ data length ]{1,2 , 3} ;

Two-dimensional arrays:

Array type [,] array variable = new data type [ number of rows, number of columns ];

int[,]a = new int [3,4];

Jagged arrays:

Data type [][]a = new data type [ number of rows ] []

Step two : define the decimal group

Data type []a1= new data type [ number of columns ]

Data type []a2= new data type [ number of columns ]

Step three: Put the decimal group in the Uncle Group

Collection

ArrayList a = new ArrayList ();

    1. Add () append

    1. Insert (,) inserts

      A.removeat () Delete the first few

      ArrayList linked list, no length limit, can add or remove elements at any time

      You need to precede the using System.Collections.

      Defined:

      ArrayList a = new ArrayList ();

      Operation:

    1. Add ( data ) append

      A.insert ( index number , data ) Insert

      A.removeat ( index number ) Delete the first few

  1. Count the number of elements in the collection.

    Value:

    a[ subscript ]

    Two:List definition:

    List < data type > A = new List < data type > ();

    List <int > A = new list <int > ();

    Operation:

    A.add ( data ) append

    A.insert ( index number , data ) Insert

    A.removeat ( index number ) Delete the first few

    A.count The number of elements in the collection.

    1. Sort (); Sort Ascending

    1. Revers (); reversal

      Three:dictionary<key,value> dictionary or hash table

      Defined:

      Dictionary<int,int> a = new Dictionary <int, int > ();

      Operation:

    1. Add ( key value, data );

    1. remove ( key value delete

       

      a.count   The number of elements in the collection.

       

      value: a[ Span style= "font-family: the song Body;" > key value

       

       

      stack< data type

       

    1. Push ( value ); add

      Data type variable name = A.pop ();

      Queue: FIFO, cannot randomly take any of its values.

      Queue a <>a = new queue <> ();

    1. Enqueue (); Add

      A.dequeue (); out

Collections and Arrays

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.