P
puzzlecracker
Does dimension o start vertically or horizontally when an array calls
GetLength() method?
In this example, just trying to understand the order it will print it,
and if I extend it to more dimensions.
static void Main()
{
int[,] twoDim = { {1, 2, 3},
{4, 5, 6},
{7, 8, 9} };
for( int i = 0; i != twoDim.GetLength(0); ++i )
{
for( int j = 0; j != twoDim.GetLength(1); ++j )
{
Console.WriteLine( twoDim[i,j] );
}
}
Also, is it possible to re-write this code using for_each loop?
Thanks
GetLength() method?
In this example, just trying to understand the order it will print it,
and if I extend it to more dimensions.
static void Main()
{
int[,] twoDim = { {1, 2, 3},
{4, 5, 6},
{7, 8, 9} };
for( int i = 0; i != twoDim.GetLength(0); ++i )
{
for( int j = 0; j != twoDim.GetLength(1); ++j )
{
Console.WriteLine( twoDim[i,j] );
}
}
Also, is it possible to re-write this code using for_each loop?
Thanks