c#固定位数的随机数:
private string rd()
{
try
{
StringBuilder sb = new StringBuilder();
Random rd = new Random(DateTime.Now.Millisecond);
for (int i = 0; i < 7; i++)
{
char c = (rd.Next(0, 9).ToString()[0]);
sb.Append(c.ToString());
}
return sb.ToString();
}
catch
{
return "1234567";
}
}
flex固定位数的随机数:
private function rd():String
{
var rd:int = int(Math.random()*9999999);
if(rd < 1000000)
rd+=1000000;
return rd.toString();
}
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2009/11/09/1598825.html,如需转载请自行联系原作者