C# 生成随机数的代码
///构造随机数种子 staticintGetRandomSeed() { byte[]bytes=newbyte[4]; System.Security.Cryptography.RNGCryptoServiceProviderrng=newSystem.Security.Cryptography.RNGCryptoServiceProvider(); rng.GetBytes(bytes); returnBitConverter.ToInt32(bytes,0); } ///生成随机数 staticintrnd() { Randomran=newRandom(GetRandomSeed()); intcnt=ran.Next(0,59); returncnt; }
以上就是本文的全部内容了,希望大家能够喜欢,能够对大家学习C#有所帮助。