Skip to content

Instantly share code, notes, and snippets.

@janell-baxter
Created June 5, 2018 21:45
Show Gist options
  • Save janell-baxter/b3c306c81915d7d3dedbda398ace97fb to your computer and use it in GitHub Desktop.
Save janell-baxter/b3c306c81915d7d3dedbda398ace97fb to your computer and use it in GitHub Desktop.
Grid Array
using System;
namespace GridArray
{
class Program
{
static void Main()
{
int[,] grid = new int[5, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 16 }, { 17, 18, 19, 20 } };
int rows = grid.GetLength(0);
int columns = grid.GetLength(1);
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
Console.Write(string.Format("{0:D2} ", grid[i, j]));
}
Console.Write("\n\n");
}
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment