我想用C#做一个抽奖机的小程序,要实现的就是输入几个人,然后点抽奖,从输入的几个人中随机取出一个中奖人
不用数据库,不想往硬盘上写东西,请问有什么办法存储这些临时数据么?

解决方案 »

  1.   

    static void Main(string[] args)
            {
                List<string> people = new List<string>();
                Console.WriteLine("Please input candidate names, one person each line, ends with an empty line:");
                string name = Console.ReadLine();
                while (name.Trim() != string.Empty) {
                    people.Add(name.Trim());
                    name = Console.ReadLine();
                }
                Random random = new Random();
                Console.WriteLine("Lucky guy is: " + people[random.Next(0,people.Count)]);
                Console.ReadLine();
            }