15,997,860 members
See more:
i have project online examination. i want to generate a random number only once second time that number not generate,because i want to select question with respect to that number.
total no of no generate is 40.
my platform is c#.net(website)
Posted
Updated 17-Mar-11 18:06pm
v2
[no name] 18-Mar-11 0:08am
Edited for Easy readablitiy and removed the email since it will be marked as spam.

## Solution 1

Albin Abel 18-Mar-11 1:13am
Good link. Really random number generation is a tricky business, because the under the hood it is a mathematical formula which generate a sequence and what we get is just a random pick from the sequence and not purely random. I feel it is good article trying for a pure random number. My 5
[no name] 18-Mar-11 1:31am
Thanks AlbinAbel.
Sandeep Mewara 18-Mar-11 3:34am
[no name] 18-Mar-11 3:35am
Thanks Sandeep.
Espen Harlinn 18-Mar-11 5:26am

## Solution 2

There is no guarantee that the chance of the number not coming again unless you remove the number from the set. Simple probability theory in 6th standard. From the deck of playing cards random choosing your queen can happen again and again unless the chosen queen is removed from the deck.

You can very well use a good random number generator as the link given by Ramalinga's or use .Net's `Random` class. If you range is large you perceive there is no repetition. But not 100% true. What you need is check before using that number that did you already got it or not. Then discard it if already got it.

v2
Sandeep Mewara 18-Mar-11 3:34am
Albin Abel 18-Mar-11 4:07am
Thanks Sandeep Mewara
Espen Harlinn 18-Mar-11 5:26am