C#获得随机数


 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace ConsoleApplication1
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             Random r = new Random();
14             int b = r.Next(0, 9);
15             Console.WriteLine("{0}",b);
16         }
17     }
18 }
Next原型:
1 public virtual int Next(
2     int minValue,
3     int maxValue
4 )

第一个控制最小值,

第二个控制最大值。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM