/// <summary> /// 獲得四位的隨機數 /// </summary> /// <returns></returns> public string Randomnum() { Random ro = new Random(); int iResult; int iUp = 999; in
//帶參數,可後期寫方法動態生成某範圍的隨機數
/// <summary>
/// 獲得四位的隨機數
/// </summary>
/// <returns></returns>
public string Randomnum()
{
Random ro = new Random();
int iResult;
int iUp = 9999;
int iDown = 1000;
iResult = ro.Next(iDown, iUp);
return iResult.ToString().Trim();
}
//不帶參數,固定隨機生成1000-9999中的一個的隨機數函數
/// <summary>
/// 獲得四位的隨機數
/// </summary>
/// <returns></returns>
public string Randomnum()
{
return new Random().Next(1000, 9999).ToString().Trim();
}