在C#中生成随机数 [英] Generate random numbers in C#

查看:153
本文介绍了在C#中生成随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

如何在(a)和(b)之间生成n个随机数,这些数字大概是(x)?



我尝试了什么:



hi。

如何在两者之间生成n个随机数(a)和(b)围绕像(x)这样的数字?

hi.
how can i generate n random number between (a) and (b) that are around a number like (x)?

What I have tried:

hi.
how can i generate n random number between (a) and (b) that are around a number like (x)?

推荐答案

Google是你的朋友,有很多答案和细节;



随机随机=新的随机();

int randomvalue = random.Next(a,b + 1);



你对像(x)这样的数字是什么意思?
Google is your friend, lots of answers and details;

Random random = new Random();
int randomvalue = random.Next(a, b + 1);

What do you mean by "on a number like (x)"?


参见这个例子: [ dotnetperls ]
See this example: [dotnetperls]


引用:

我如何在(a)和(b)之间生成n个随机数,这些数字类似于( x)?

how can i generate n random number between (a) and (b) that are around a number like (x)?



C#有随机函数,第一步是读取电子文档。


C# have random function, first step is to read the documentation.


这篇关于在C#中生成随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆