最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net Random随机函数使用方法
时间:2011-04-19 编辑:简简单单 来源:一聚教程网
随机数计算的根源,就是随机种子数,我原来用的是时间的毫秒,但是时间太快的话,就会导致取出的数字一样
如果加入调用次数作为参数呢:
asp教程.net中应用
<%@ page language="c#" contenttype="text/html" responseencoding="gb2312" %>
测试实例
public static class getint
{
public static int c;
public static int getone()
{
c++;
random ran = new random(datetime.now.millisecond + c);
return ran.next(0, getarg.getmax());
}
}
官网实例
byte[] bytes1 = new byte[100];
byte[] bytes2 = new byte[100];
random rnd1 = new random();
random rnd2 = new random();rnd1.nextbytes(bytes1);
rnd2.nextbytes(bytes2);console.writeline("first series:");
for (int ctr = bytes1.getlowerbound(0);
ctr <= bytes1.getupperbound(0);
ctr++) {
console.write("{0, 5}", bytes1[ctr]);
if ((ctr + 1) % 10 == 0) console.writeline();
}
console.writeline();
console.writeline("second series:");
for (int ctr = bytes2.getlowerbound(0);
ctr <= bytes2.getupperbound(0);
ctr++) {
console.write("{0, 5}", bytes2[ctr]);
if ((ctr + 1) % 10 == 0) console.writeline();
}
相关文章
- asp.net 析构函数详解与用法 06-14
- 检测是否还有黑客代码的asp.net函数 ouwx(原作) 01-12
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18