I am familiar with Random
and RNGCryptoServiceProvider
and how they can be used to generate random numbers in C#.
But I am also aware of the following method:
int start = 10;
int end = 50;
Enumerable.Range(start, end).OrderBy(o => Guid.NewGuid()).Take(5);
Given the streaming power of LINQ
and the given thread-safety of this method (as opposed to using a shared Random
) I cannot find a reason not to use this method.
What am I missing other than performance?