loop for a 2d array in csharp

main.cs
int[,] array2D = new int[3, 3] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };

for (int i = 0; i < array2D.GetLength(0); i++)
{
    for (int j = 0; j < array2D.GetLength(1); j++)
    {
        Console.WriteLine("Value at ({0}, {1}): {2}", i, j, array2D[i, j]);
    }
}
265 chars
10 lines

related categories

gistlibby LogSnag