Im a beginner at programming and im currently learning C# in school. I've got a task to make an array containing every number between 1-20 in order of size. Then randomize the order in which the numbers appear in the array. I've tried different methods, but i can't seem to get it to work. This is what im working with at the moment:
int random = 0;
Random rNG = new Random();
int[] twenty = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
int[] check = new int[20];
for (int i = 0; i < 20; i++)
{
random = rNG.Next(1, 21);
foreach (int check2 in check)
{
if (random != check2)
{
check[i] = random;
twenty[i] = random;
break;
}
}
}
foreach (int write in twenty)
{
Console.Write(write + ", ");
}
Coding in Visual Studio 2015 in a console project.
Thanks in advance for the help/suggestions!