日期:2014-05-17  浏览次数:20883 次

新手求教各位大侠一个弱弱的问题 ???如何实现点任意键输出随机数???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace roll
{
    class Program
    {
        static void Main(string[] args)
        {
            int nbr = 0;
            System.Random rnd = new Random();
            nbr = (int)rnd.Next(1, 7);
            Console.ReadLine();
            
            switch(nbr)
            {
                case 1:
                    Console.WriteLine("1");
                    break;
                case 2:
                    Console.WriteLine("2");
                    break;
                case 3:
                    Console.WriteLine("3");
                    break;
                case 4:
                    Console.WriteLine("4");
                    break;
                case 5:
                    Console.WriteLine("5");
                    break;
                case 6:
                    Console.WriteLine("6");
                    break;
                default: break;
            }
            Console.ReadKey();
        }
    }
}