本文讲解C#如何读取二维数组的行数列数。
读取二维数组的行数和列数实例如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace arrayDemo
{
class Program
{
static void Main(string[] args)
{
int[,] array = { {1, 2, 3},{4, 5, 6}, {7, 8, 9}, {10, 11, 12 } };
//GetLength(0)第一维的长度(即行数)
//GetLength(1)第二维的长度(即列数)
int rows = array.GetLength(0); // 获取行数
int columns = array.GetLength(1); // 获取列数
Console.WriteLine("行数: " + rows);
Console.WriteLine("列数: " + columns);
//使用嵌套循环来遍历二位数组
for (int i