Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to generate random number without repetition in C #
Posted
Comments
Herman<T>.Instance 26-Nov-12 5:41am    
show us your code
rasol123 26-Nov-12 5:49am    
Function to prevent the entry of the previously random number is generated, for example, in VB

Provided the set of possible candidates is 'reasonably small', I described a method here: "Random extraction of 5 cards from a deck"[^]. Is C++ code, but, in this case, just the algorithm matters.
 
Share this answer
 
GUID, that is what you use[^]
 
Share this answer
 
you can use Random class of .NET.

use following code:

C#
Random random = new Random();
int num = random.Next();
 
Share this answer
 
Hi,

use the below code to generate.
Random integer between 0 and 100 here 100 is not included)
C#
Random random = new Random();
int randomNumber = random.Next(0, 100);//Give the range in which you want to generate.
;

Or refer the below link.
Random Number Generation[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900