在C#中如何写个生成随机数字的函数?

解决方案 »

  1.   

       Random r = new Random();
                r.Next();具体看一下就知道了
      

  2.   


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Reflection;
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                
                Random a = new Random();
                int max = 999;
                int min = -999;
                for (int m = 0; m < 100; m++)
                {
                    Console.WriteLine(a.Next(min, max));
                }
                Console.ReadLine();
                
            }
        }}
      

  3.   

    Random ran=new Random(DateTime.Now.Millisecond)
    int i=rnd.Next(1,100);