


Detailed introduction to using C# to describe data structure 2: Array graphic code example
Mar 08, 2017 am 11:51 AM Array is the most basic data collection provided by .NET, which directly accesses collection elements through indexes. Provides one-dimensional or multi-dimensional data storage and supports operations such as query, search, sorting, copying, etc. The main interfaces provided by
are divided according to semantics, mainly including:
You can also check Baidu Brain Map:
http:/ /naotu.baidu.com/file/f879a94fe2163c365cc22f4e4bbcc7dc
One-dimensional array declaration, creation, initialization:
1) Directly in 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] = 10; mp[4] = 30; mp[5] = 50;
As shown in the figure below, the numbers of the one-dimensional graphs are 0,1,2,3,4,5 respectively

int[,] point = new int[2, 6] { { -50, -30, -10, 10, 30, 50 },//第0维 { 50, 30, 10, 10, 30, 50 }//第1维 };
//点0 point[0, 0] = -50; point[1, 0] = 50; //点1 point[0, 1] = -30; point[1, 1] = 30; //点2 point[0, 2] = -10; point[1, 2] = 10; //点3 point[0, 3] = 10; point[1, 3] = 10; //点4 point[0, 4] = 30; point[1, 4] = 30; //点5 point[0, 5] = 50; point[1, 5] = 50;
//获取某维的元素个数 int mpLen0 = mp.GetLength(0);//6 int pointLen0 = point.GetLength(0);//2 int pointLen1 = point.GetLength(1);//6 //获取某个维度的下标最大值 int mpUpperBound = mp.GetUpperBound(0); //5 int pointUpperBound0 = point.GetUpperBound(0);//1 int pointUpperBound1 = point.GetUpperBound(1);//5 //获取某个维度的下标最小值 int mpLowBound = mp.GetLowerBound(0);//0 int pointLowBound0 = point.GetLowerBound(0);//0 int pointLowBound1 = point.GetLowerBound(1);//0 //获取所有维数的元素总数 int mpLen = mp.Length;//6 int pointLen = point.Length;//12 //获取维数 int mpRank = mp.Rank;//1 int pointRank = point.Rank;//2
Summary 1 Array must determine the number of elements in each dimension of the element when compiling. This is its biggest flaw. For situations where the number of elements in a certain dimension can only be determined at runtime, this data structure cannot meet the conditions!
2 The type of Array when it is created is a strong type and must be specified.
Download address of Array mind map:
http://download.csdn.net/detail/daigualu/9772336
Test source code download address:
http://download.csdn. net/my
The above is the detailed content of Detailed introduction to using C# to describe data structure 2: Array graphic code example. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
