Created
October 3, 2019 16:46
-
-
Save peterthorsteinson/14091337f80172e112a2240f305c1e05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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