/// <summary> From:www.uzhanbao.com
/// 隨機生成電話號碼
/// </summary>
/// <returns></returns>
public string getRandomTel()
{
Random ran = new Random(Guid.NewGuid().GetHashCode());
//aa = r.Next(a1, a2);
//foundMatch = Regex.IsMatch(strReturn, @"^(13[0-9]|147|15[0-9]|166|17[0-9]|18[0-9])\d{8}$");//正則匹配手機號碼的格式
string[] telStarts = "130,131,132,133,134,135,136,137,138,139,147,150,151,152,153,155,156,157,158,159,180,181,182,183,185,186,187,188,189,176,177,178,199,198,166".Split(',');
int n = ran.Next(10, 1000);
int index = ran.Next(0, telStarts.Length - 1);
string first = telStarts[index];
string second = (ran.Next(100, 888) + 10000).ToString().Substring(1);
string thrid = (ran.Next(1, 9100) + 10000).ToString().Substring(1);
return first + second + thrid;
}
c# 隨機生成電話號碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.