Skip to content

Instantly share code, notes, and snippets.

@patbonecrusher
Last active September 28, 2017 17:24
Show Gist options
  • Save patbonecrusher/6039477 to your computer and use it in GitHub Desktop.
Save patbonecrusher/6039477 to your computer and use it in GitHub Desktop.
Generating a sequence of unique random numbers in C#
Random rnd = new Random();
var randomNumbers = Enumerable.Range(1, 100)
.Select(x => new { val = x, order = rnd.Next() })
.OrderBy(i => i.order)
.Select(x => x.val)
.ToArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment