手机
当前位置:查字典教程网 >编程开发 >C#教程 >c#生成随机数示例分享
c#生成随机数示例分享
摘要:复制代码代码如下:///构造随机数种子staticintGetRandomSeed(){byte[]bytes=newbyte[4];Sys...

复制代码 代码如下:

/// 构造随机数 种子

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#调用Matlab生成的dll方法的详细说明

c#中返回文章发表的时间差的示例

c# 类和成员的修饰详细介绍

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

C# DataTable的详细用法分享

用C#生成不重复的随机数的代码

c# 生成随机时间的小例子

c# 泛型类型参数与约束的深入分析

C#常用正则大全分享

精品推荐
分类导航