so i've been working on a project, and i made this method to take up to 16 values in an array and randomize them into a list. i thought this should have worked but it didnt, whenever it runs it crashes the program but it compiles just fine.
array has "numOfTeams" amount of indexes
private List<string> randomizer()
{
List<string> myList = new List<string>();
Random rand = new Random();
int randomVar;
while (myList.Count < numOfTeams)
{
randomVar = rand.Next(0, numOfTeams + 1);
if (array[randomVar] != "null")
{
myList.Add(array[randomVar]);
array[randomVar] = "null";
}
}
return myList;
}