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 RandomT开发者_运维问答olerance
to choose between 5 and 10 only as an integer.
int RandomTolerance=random.Next(0,2)<1?5:10;
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.
int RandomTolerance = random.Next(1,3) * 5;
Disclaimer: @Blindy, this sounded better :)
精彩评论