nums.Length
is used by the
for
loops to govern the
number of iterations that take place. Since each array carries with it its own length, you can
use this information rather than manually keeping track of an array’s size. Keep in mind
that the value of
Length
has nothing to do with the number of elements that are actually in
use.
Length
contains the number of elements that the array is capable of holding.
When the length of a multidimensional array is obtained, the total number of elements
that can be held by the array is returned. For example:
// Use the Length array property on a 3D array.
using System;
class LengthDemo3D {
static void Main() {
int[,,] nums = new int[10, 5, 6];
Console.WriteLine("Length of nums is " + nums.Length);
}
}
www.freepdf-books.com
Do'stlaringiz bilan baham: |