A detailed description of graphic code examples describing data structure 2:array in C #

Source: Internet
Author: User

The array is the most basic data collection provided by. NET, which accesses the collection elements directly through the index. Provides one-dimensional or multidimensional data storage and supports operations such as, querying, searching, sorting, copying, and so on.

The main interfaces provided, according to the semantic division, mainly include:

Also can hit Baidu brain map View:
Http://naotu.baidu.com/file/f879a94fe2163c365cc22f4e4bbcc7dc

One-dimensional array declaration, creation, initialization:
1) directly within the initializer:

           Int[] MP = new Int[6] {-50,-30,-10, 10, 30, 50};

2) Assign values separately:

            Mp[0] = -50;            MP[1] = -30;            MP[2] = -10;            MP[3] = ten;            MP[4] =;            MP[5] = 50;

As shown, the number of one-dimensional graphs is 0,1,2,3,4,5




Multidimensional (for example, two-dimensional) array declaration, creation, initialization: (as shown, two-dimensional numbering is 0,1,2,3,4,5)

            int[,] point = new int[2, 6] {             {-50,-30,-10, 10, 30, 50},//No. 0 dimension             {50, 30, 10, 10, 30, 50}//1th dimension                                          };

Initialize separately:

            Point 0            point[0, 0] = -50;            point[1, 0] =;            Point 1            point[0, 1] = -30;            Point[1, 1] =;            Point 2            point[0, 2] = -10;            Point[1, 2] = ten;            Point 3            point[0, 3] = ten;            Point[1, 3] = ten;            Point 4            point[0, 4] =;            Point[1, 4] =;            Point 5            point[0, 5] =;            Point[1, 5] = 50;

The semantic differences between one-dimensional and multidimensional-interface methods were compared:

//Get the number of elements of a dimension int mpLen0 = MP. GetLength (0);//6 int pointLen0 = point. GetLength (0);//2 int pointLen1 = point. GetLength (1);//6//Gets the subscript maximum value of a dimension int mpupperbound = MP. GetUpperBound (0); 5 int pointUpperBound0 = point. GetUpperBound (0);//1 int pointUpperBound1 = point. GetUpperBound (1);//5//Gets the subscript minimum value for a dimension int mplowbound = MP. Getlowerbound (0);//0 int pointLowBound0 = point. Getlowerbound (0);//0 int pointLowBound1 = point. Getlowerbound (1);//0//Gets the total number of elements of all dimensions int mplen = MP. LENGTH;//6 int pointlen = point. LENGTH;//12//Gets the number of dimensions int mprank = MP. RANK;//1 int pointrank = point. RANK;//2 

summary
1 array at compile time must determine the number of elements in each dimension of the element, which is its biggest flaw, for the runtime to determine the number of elements of a dimension, This data structure is not satisfied with the condition! The
2 array is created with a strongly typed type and must be specified.

Download the array Mind map address:
http://download.csdn.net/detail/daigualu/9772336
Test source download Address:
HTTP://DOWNLOAD.CSD N.net/my

Related Article

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.