C#的随机种子

private static int GetRandomSeed()
{
        byte[] bytes = new byte[4];
        System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();
        rng.GetBytes(bytes);
        return BitConverter.ToInt32(bytes, 0);
}

每次使用Random,总觉得找不到好的随机种子,上面这个不错哈!

你可能感兴趣的:(.NET)