2

MSDN チュートリアルから C# 配列構文を学んでいます。次のコードがあります。

// Array-of-arrays (jagged array)
byte[][] scores = new byte[5][];

// Create the jagged array
for (int i = 0; i < scores.Length; i++)
{
    scores[i] = new byte[i + 3];
}

// Print length of each row
for (int i = 0; i < scores.Length; i++)
{
    Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length);
    Console.ReadLine();
}

出力は次のようになります。

Length of row 0 is 3
Length of row 1 is 4
Length of row 2 is 5
Length of row 3 is 6
Length of row 4 is 7

コードをコピーしてコンソール アプリケーションのメイン メソッドに貼り付けたところ、コンソールの出力は次のようになりました。

Length of row 0 is 3

私の出力が異なる理由を知っている人はいますか?

4

3 に答える 3

5

あなたのプログラムは、出力の連続する行の間に Enter を押すように求めています:

Console.ReadLine();
于 2013-08-25T03:26:55.227 に答える