C# 生成随机数的代码
作者:hebedich 时间:2021-06-16 06:05:43
/// 构造随机数 种子
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#,随机数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
详解Spring循环依赖的解决方案
2022-05-29 13:14:57
Java Object定义三个点实现代码
2023-11-21 06:05:07
Mybatis Plus select 实现只查询部分字段
2022-07-23 18:51:32
![](https://img.aspxhome.com/file/2023/9/61279_0s.jpg)
spring与mybatis三种整合方法
2021-11-27 22:00:46
Spring中BeanFactory与FactoryBean接口的区别详解
2022-06-17 11:22:22
![](https://img.aspxhome.com/file/2023/1/66501_0s.jpg)
SpringBoot集成EasyExcel的应用场景分析
2023-01-09 07:47:45
![](https://img.aspxhome.com/file/2023/6/78876_0s.png)
SpringBoot security安全认证登录的实现方法
2021-05-30 08:09:56
![](https://img.aspxhome.com/file/2023/5/63685_0s.png)
Android实现自动匹配关键字并且标红功能
2023-05-29 06:19:28
C#4.0新特性之协变与逆变实例分析
2022-02-18 00:17:28
Android Activity 不能被截屏的解决方法
2021-06-28 08:37:35
Unity 从Resources中动态加载Sprite图片的操作
2023-08-26 11:37:18
老生常谈Java中List与ArrayList的区别
2023-03-26 19:52:33
![](https://img.aspxhome.com/file/2023/6/60916_0s.png)
Tornadofx学习笔记之IconTextFx开源库整合5000+个字体图标
2023-06-07 12:18:04
![](https://img.aspxhome.com/file/2023/8/77338_0s.jpg)
Java中Function的使用及说明
2023-08-12 03:04:29
![](https://img.aspxhome.com/file/2023/5/58025_0s.png)
Java 高并发十: JDK8对并发的新支持详解
2022-12-02 02:43:09
![](https://img.aspxhome.com/file/2023/6/75506_0s.png)
C#获取程序文件相关信息的方法
2021-12-12 05:34:51
C#使用SQL Dataset数据集代码实例
2023-02-24 08:23:07
Java面试题冲刺第二十二天-- Nginx
2023-11-16 13:43:48
![](https://img.aspxhome.com/file/2023/6/58916_0s.png)
不看后悔!揭秘游戏服务器开发
2023-08-22 16:20:30
![](https://img.aspxhome.com/file/2023/6/58306_0s.png)
C#实现的XML操作类实例
2022-04-04 12:17:37