今天同事問到怎麼產生亂數字串,我把上次寫的方式貼給他,也就順便貼出來,當作備忘。
public static string GetRandomString()
{
return Path.GetRandomFileName().Replace(".", ""); //出來長度為11,請自行改長度
}
public static int GetRandomInteger()
{
Random r = new Random();
return r.Next(1000); //自己改亂數範圍
}

No comments:
Post a Comment