最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net Random随机函数使用方法
时间:2022-06-25 04:16:38 编辑:袖梨 来源:一聚教程网
随机数计算的根源,就是随机种子数,我原来用的是时间的毫秒,但是时间太快的话,就会导致取出的数字一样
如果加入调用次数作为参数呢:
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();
}
相关文章
- 嘟嘟脸恶作剧爱蜜莉雅角色怎么样 09-18
- 地狱即我们塔尔居怎么过 第七章剧情流程视频攻略 09-18
- 地狱即我们坎侬湖怎么过 第六章剧情流程视频攻略 09-18
- 无主之地4武器闪光皮肤获得方法 武器闪光皮肤怎么获得 09-18
- 地狱即我们维萨山区怎么过 第五章剧情流程视频攻略 09-18
- 燕云十六声信笺连年任务怎么做-万事知信笺连年任务攻略 09-18