Generating Random Numbers
A fairly common task is to generate random numbers (for example, to create a random permutation of objects in a collection, to write a lottery application, to generate test input sequences). The
System namespace contains a
Random class that’s designed for this purpose, producing what’s known as a pseudo-random sequence.
Note: Security, Security, Security
It can’t be emphasized enough that the
Random class is not well suited for use in a security-critical context (for example, to provide cryptographic strength random numbers) in part due to its pseudo-random (and hence predictable) nature.
For such uses, the
System.Security.Cryptography namespace should be put into action, with its
RandomNumberGenerator base class and ...