Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/0aa22f5f3760a272668e to your computer and use it in GitHub Desktop.
Save icebeam7/0aa22f5f3760a272668e to your computer and use it in GitHub Desktop.
// Get a list of non-repeatable random numbers
List<int> GenerateRandomList(Random random, int size)
{
int num, i = 0;
List<int> list = new List<int>();
do{
num = random.Next(0, size) + 1;
if (!list.Contains(num))
{
list.Add(num);
i++;
}
} while (i < size);
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment