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