Skip to content

Instantly share code, notes, and snippets.

@peterthorsteinson
Created October 3, 2019 16:46
Show Gist options
  • Save peterthorsteinson/14091337f80172e112a2240f305c1e05 to your computer and use it in GitHub Desktop.
Save peterthorsteinson/14091337f80172e112a2240f305c1e05 to your computer and use it in GitHub Desktop.
using System;
namespace RandomArray
{
class Program
{
static void Main()
{
int[,] intArray2D = new int[10, 20];
Display(intArray2D);
System.Random rnd = new Random();
for (int i = 0; i < intArray2D.GetLength(0); i++)
{
for (int j = 0; j < intArray2D.GetLength(1); j++)
{
intArray2D[i, j] = rnd.Next(0, 100);
}
}
Console.WriteLine();
Display(intArray2D);
}
static void Display(int[,] intArray2D)
{
for (int i = 0; i < intArray2D.GetLength(0); i++)
{
for (int j = 0; j < intArray2D.GetLength(1); j++)
{
Console.Write("{0,3:D1} ", intArray2D[i, j]);
}
Console.WriteLine();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment