随机选择 2 个 Int 作为选项
private void btnStart_Click(object sender, EventArgs e)
{
Random random = new Random();
int randomNumber = random.Next(0, 1000);
int RandomTolerance = 5 || 10;
lblRandomValue.Text = randomNumber + "000" + "O" + RandomTolerance;
}
我不明白如何允许 RandomTolerance
仅在 5 和 10 之间选择整数。
private void btnStart_Click(object sender, EventArgs e)
{
Random random = new Random();
int randomNumber = random.Next(0, 1000);
int RandomTolerance = 5 || 10;
lblRandomValue.Text = randomNumber + "000" + "O" + RandomTolerance;
}
I do not understand how to allow the RandomTolerance
to choose between 5 and 10 only as an integer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
顺便说一句,一遍又一遍地重新播种随机数生成器通常是一个坏主意。您应该阅读随机数生成器的工作原理。
As a side note, reseeding your random number generator over and over is usually a bad idea. You should read up on how random number generators work.
免责声明:@Blindy,这听起来更好:)
Disclaimer: @Blindy, this sounded better :)