Two-dimensional arrays

Source: Internet
Author: User

two-dimensional array: it represents a tabular data. There are rows and columns. The same as the array: All data is of the same type, and the number of stores is fixed. the creation of a two-dimensional array of one or two-only arrays is characterized by rows and columns. The type of the element [,] The name of the array =new the type of the element [number of rows, number of columns];int[,] arr=new int[4, 3]; represents a table structure that declares a specified number of rows, each row has a specified number of columns. Number of elements in a two-dimensional array: number of rows * ColumnsIi. assigning values to elements in a two-dimensional arraythe elements in a two-dimensional array must be determined by the row and column two coordinates. Determine the number of columns in the first row of this element. the row and column coordinates in a two-dimensional array start at 0. You can navigate to the specified element by writing the upstream and column coordinates in the indexer. arr[Line coordinates, column coordinate]= value;third, the value:values are still taken by row coordinates and column coordinates. A one-dimensional array represents a line. Make sure a point on the line is just one coordinate. A two-dimensional array represents a polygon. To determine a point on a face 2 coordinates Four, TraverseThe length property represents the number of elements in the array, while the length in the two-dimensional array refers to the row * columnA, using foreach can be easily and quickly traversed. B, the GetLength () of the array can get the length of the specified latitude. Pass in 0 to get the number of rows. incoming 1 can get the number of columns for (int i=0;i<arr. GetLength (0); i++){for (int j=0;j<arr. GetLength (1); j + +)                  {Console.Write (Arr[i,j]);                  }Console.WriteLine ();}The rank property of the array can be used to get the dimensions of the array    PS: three-dimensional arrayint[,,] arr=new int[3, 5, 4];      

Two-dimensional arrays

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.