C# 随机生成名字,电话,图像

  1 随机生成3个字的名字 【可直接看效果图】

public static List GetTels(int count)
 {
           List tels = new List() { };

           string[] tel1 = new string[] { "130", "187", "156", "179", "188", "199", "180","176","190"};


           Random rad = new Random();//实例化随机数产生器rad;
            
           for (int i = 0; i < count;i++ )
           {
               string tel = tel1[rad.Next(0, tel1.Length - 1)] + StringUtils.FillZero(rad.Next(1000, 10000),4)+StringUtils.FillZero(rad.Next(1000, 10000),4);
               if (tels.Contains(tel) == false)
               {
                   tels.Add(tel);
               }
               else
               {
                   i--;
               }
           }


           return tels;
    
}



public sta

你可能感兴趣的:(C#,开发总结,C#,随机生成名字,随机生成电话号码,随机生成头像)