假设我有以下内容:
public void MakeMatrix(int matrixLength)
{
int[,] Matrix = new Matrix[matrixLength,matrixLength]
PopulateMatrix(Matrix);
PrintMatrix(Matrix);
}
在PrintMatrix(int[,] Matrix)
函数中,如何找到多维数组中只有一维的长度?
public void PrintMatrix(int[,] Matrix)
{
int intLength = // I don't know what to put here <===================
for (int k = 0; k < intLength ; k++)
{
for (int l = 0; l < intLength; l++)
{
Console.Write("{0,2} ", Matrix[k, l]);
}
Console.WriteLine();
}
}
答案 0 :(得分:14)
为什么不
Matrix.GetLength(0)