C# 生成隨機數的代碼
阿新 • • 發佈:2017-12-14
圖片 rec solid 添加 文檔 normal crypto () margin
C# 生成隨機數的代碼
本文地址: http://www.paobuke.com/develop/c-develop/pbk23093.html
C#簡單實現子窗體向父窗體傳值的方法C#中實現判斷某個類是否實現了某個接口C#解決漢諾塔問題DEMOC#調用執行外部程序的實現方法
/// 構造隨機數 種子 static int GetRandomSeed() { byte[] bytes = new byte[4]; System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); rng.GetBytes(bytes); return BitConverter.ToInt32(bytes, 0); } /// 生成隨機 數 static int rnd() { Random ran = new Random(GetRandomSeed()); int cnt = ran.Next(0,59); return cnt; }
以上就是本文的全部內容了,希望大家能夠喜歡,能夠對大家學習C#有所幫助。
除聲明外,跑步客文章均為原創,轉載請以鏈接形式標明本文地址C# 生成隨機數的代碼
本文地址: http://www.paobuke.com/develop/c-develop/pbk23093.html
相關內容
在C#裏面給PPT文檔添加註釋的實現代碼C# 中的var關鍵字詳細介紹C#實現Winform版計算器C#操作IIS方法集合C#簡單實現子窗體向父窗體傳值的方法C#中實現判斷某個類是否實現了某個接口C#解決漢諾塔問題DEMOC#調用執行外部程序的實現方法
C# 生成隨機數的代碼