I wanna generate a random number between 1 and 10 that doesn't equal 8, for example.
this will generate a random number between 1 and 10, but how can I set it not to equal 8?
I know I can do
but when it comes to many variables and many exceptions it's very time consuming. Is there a better way to do this?
C#:
[COLOR=#000000][FONT=Helvetica] Random rnd = new Random();[/FONT][/COLOR]
[COLOR=#000000][FONT=Helvetica] int a = rnd.Next(1,11);[/FONT][/COLOR]
I know I can do
C#:
[COLOR=#000000][FONT=Helvetica]Start:[/FONT][/COLOR]
[COLOR=#000000][FONT=Helvetica] Random rnd = new Random();[/FONT][/COLOR]
[COLOR=#000000][FONT=Helvetica] int a = rnd.Next(1,11);[/FONT][/COLOR]
[COLOR=#000000][FONT=Helvetica] if(a == 8){[/FONT][/COLOR]
[COLOR=#000000][FONT=Helvetica] goto Start;[/FONT][/COLOR]
[COLOR=#000000][FONT=Helvetica] }[/FONT][/COLOR]
but when it comes to many variables and many exceptions it's very time consuming. Is there a better way to do this?