C#和Javascript产生随机数的方法

    技术2022-05-12  39

     C#产生随机数的方法:

       Random rand = new Random();

             rand.Next(1000, 9999999);

             将产生1000-9999999里面随机的一个数字

     

     

    JavaScript中产生随机数的方法:

            Math.random()方法将返回0~1之间的随机浮点型

        若要产生不同范围的随机数,使用"Math.floor(Math.random()*n)+m",

       其中m上下限,n是上限.

       另外:Math对象中的round(n)方法返回n的四舍五入值


    最新回复(0)