编程语言
首页 > 编程语言> > C# 随机点名小程序

C# 随机点名小程序

作者:互联网

string[] arr = { "张三", "李四", "王五", "Curry", "James", "Kobe" };
Random rand = new Random();//实例化rand
string name1 = arr[rand.Next(0, arr.Length)];
//string name2 = arr[rand.Next(0, arr.Length)];
 Console.WriteLine("恭喜{0}中奖了", name1);

 

标签:rand,arr,点名,string,C#,Next,Length,随机,name1
来源: https://www.cnblogs.com/zwnsyw/p/15427347.html