Hi David,
I don't know your context, so I don't know whether this method is the best.
So, in addition to the others, let me also suggest using the
RNGCryptoServiceProvider class (in the System.Security.Cryptography
namespace), which derives from the RandomNumberGenerator class.
Eg: (in the context of creating a salt)
byte[] saltInBytes = new byte[8];
RNGCryptoServiceProvider saltGenerator = new RNGCryptoServiceProvider();
saltGenerator.GetBytes(saltInBytes);
string saltAsString = Convert.ToBase64String(saltInBytes);
HTH,
Rakesh Rajan