代码如下:
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
Type text here
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
转载于:https://www.cnblogs.com/rainnight/archive/2008/03/23/1118275.html
最后
以上就是英勇小馒头最近收集整理的关于ASP.NET取指定长度的随机数的全部内容,更多相关ASP.NET取指定长度内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复