手机
当前位置:查字典教程网 >编程开发 >C#教程 >C# 生成随机数的代码
C# 生成随机数的代码
摘要:///构造随机数种子staticintGetRandomSeed(){byte[]bytes=newbyte[4];System.Secur...

/// 构造随机数 种子 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); } /// 生成随机 数 static int rnd() { Random ran = new Random(GetRandomSeed()); int cnt = ran.Next(0,59); return cnt; }

以上就是本文的全部内容了,希望大家能够喜欢,能够对大家学习C#有所帮助。

【C# 生成随机数的代码】相关文章:

深入反射生成数组的详解

C#中方法的详细介绍

C#中常使用进度条的代码

C#求解哈夫曼树,实例代码

c#生成缩略图的实现方法

C#生成随机字符串的实例

C#委托初级使用的实例代码

C#重启远程计算机的代码

C#版ftp方法实现类的代码

用C#写的ADSL拨号程序的代码示例

精品推荐
分类导航