【原】C#二維數組的遍歷


int[,] array =  new  int[ 3, 2];
array[ 0, 0] =  1;
array[ 1, 0] =  2;
array[ 2, 0] =  3;
array[ 0, 1] =  4;
array[ 1, 1] =  5;
array[ 2, 1] =  6;

Console.WriteLine( " 數組的長度為{0} ", array.Length);
/*
Console.WriteLine(array.GetLength(0));
Console.WriteLine(array.GetLength(1));
*/
for ( int i =  0; i < array.GetLength( 0); i++)
{
     for ( int j =  0; j < array.GetLength( 1); j++)
    {
        Console.WriteLine(array[i, j]);
    }
}
            


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM