最新下载
热门教程
- 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();
}
相关文章
- 杖剑传说贤者命运果实抽取推荐 07-01
- Robinhood 夏日戛纳的高调产品发布会,彻底引爆链上券商竞赛 07-01
- 银与绯主线10-8通关阵容攻略分享 07-01
- 伊莫跨平台互通功能详解 全平台数据同步体验 07-01
- 问题汇总:币圈技术分析使用的5个基本指标 07-01
- Tether疯狂出手:合规大势下,野蛮生长的“稳定币之王”焦虑了? 07-01