会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
草上飞博客
博客园
首页
新随笔
联系
订阅
管理
ASP.NET取指定长度的随机数
代码如下:
Type text here
Code
1
//
2
/**/
///
取得随机数
3
///
4
///
随机数的长度
5
///
6
public
static
string
getrandnum(
int
randnumlength )
7
{
8
system.random randnum
=
new
system.random(
unchecked
( (
int
) datetime.now.ticks ) );
9
stringbuilder sb
=
new
stringbuilder( randnumlength );
10
for
(
int
i
=
0
; i
<
randnumlength; i
++
)
11
{
12
sb.append( randnum.next(
0
,
9
) );
13
}
14
return
sb.tostring();
15
}
16
17
#endregion
18
posted @
2008-03-23 09:07
飘渺峰
阅读(
321
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告