ASP.NET取指定长度的随机数

代码如下:
Type text here
Code
 1// 
 2/**//// 取得随机数 
 3/// 
 4/// 随机数的长度 
 5/// 

 6public static string getrandnum( int randnumlength ) 
 7
 8system.random randnum = new system.random( unchecked( ( int ) datetime.now.ticks ) ); 
 9stringbuilder sb = new stringbuilder( randnumlength ); 
10for ( int i = 0; i < randnumlength; i++ ) 
11
12sb.append( randnum.next( 09 ) ); 
13}
 
14return sb.tostring(); 
15}
 
16
17#endregion 
18

转载于:https://www.cnblogs.com/rainnight/archive/2008/03/23/1118275.html

你可能感兴趣的:(ASP.NET取指定长度的随机数)