Click here to Skip to main content
16,005,697 members
Home / Discussions / C#
   

C#

 
GeneralRe: Same Random Numbers Pin
leppie14-Jul-08 22:32
leppie14-Jul-08 22:32 
GeneralRe: Same Random Numbers Pin
DaveyM6914-Jul-08 5:48
professionalDaveyM6914-Jul-08 5:48 
AnswerRe: Same Random Numbers Pin
erfi14-Jul-08 5:57
erfi14-Jul-08 5:57 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 6:01
humayunlalzad14-Jul-08 6:01 
GeneralRe: Same Random Numbers Pin
hammerstein0514-Jul-08 6:23
hammerstein0514-Jul-08 6:23 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 6:28
humayunlalzad14-Jul-08 6:28 
AnswerRe: Same Random Numbers Pin
Paul Conrad14-Jul-08 7:00
professionalPaul Conrad14-Jul-08 7:00 
AnswerRe: Same Random Numbers Pin
Robert.C.Cartaino14-Jul-08 11:52
Robert.C.Cartaino14-Jul-08 11:52 
I don't think you gain anything by having two separate random number generators. Your .add() call should probably read:
myEmployeeCollection.Add(new Employee(100 + i,rnd.Next(50),("name"+ rnd.Next(50))));
... using only one instance of the Random() class.

Random number generators use some formula to generate a sequence numbers that provide the appearance of randomness with a good distribution (i.e. pseudorandom). As you found out, a random number generator starting with the same seed will always produce the same sequence of numbers.

Even with different seeds, there is a maximum length before the sequence begins to repeat (yes, it is a very long time but...). If you run two instances of the same formula with different entry points (seeds) in parallel, there is always a possibility that they are running sufficiently close in the sequence that the distribution between the two sets of numbers is no longer sufficiently random.

Why mess with it? Just use one random number generator.

Robert C. Cartaino
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 18:42
humayunlalzad14-Jul-08 18:42 
Questionloop break on KeyDown [modified] Pin
erfi14-Jul-08 5:21
erfi14-Jul-08 5:21 
AnswerRe: loop break on KeyDown Pin
Harvey Saayman14-Jul-08 5:25
Harvey Saayman14-Jul-08 5:25 
AnswerRe: loop break on KeyDown Pin
paas14-Jul-08 6:44
paas14-Jul-08 6:44 
AnswerRe: loop break on KeyDown Pin
Frank Horn14-Jul-08 8:08
Frank Horn14-Jul-08 8:08 
QuestionQuick search with datagrid & textbox! Pin
Yosh_14-Jul-08 5:03
professionalYosh_14-Jul-08 5:03 
AnswerRe: Quick search with datagrid & textbox! Pin
paas14-Jul-08 6:49
paas14-Jul-08 6:49 
GeneralRe: Quick search with datagrid & textbox! Pin
Yosh_17-Jul-08 6:47
professionalYosh_17-Jul-08 6:47 
GeneralRe: Quick search with datagrid & textbox! Pin
paas18-Jul-08 2:59
paas18-Jul-08 2:59 
QuestionStarting explorer Pin
ajtunbridge14-Jul-08 4:52
ajtunbridge14-Jul-08 4:52 
AnswerRe: Starting explorer Pin
DaveyM6914-Jul-08 5:19
professionalDaveyM6914-Jul-08 5:19 
AnswerRe: Starting explorer Pin
TheFM23414-Jul-08 6:58
TheFM23414-Jul-08 6:58 
GeneralRe: Starting explorer Pin
ajtunbridge14-Jul-08 8:49
ajtunbridge14-Jul-08 8:49 
QuestionDecimal symbol in Regional settings [modified] Pin
serega2007us14-Jul-08 4:13
serega2007us14-Jul-08 4:13 
AnswerRe: Decimal symbol in Regional settings Pin
DaveyM6914-Jul-08 4:31
professionalDaveyM6914-Jul-08 4:31 
GeneralRe: Decimal symbol in Regional settings Pin
serega2007us14-Jul-08 4:40
serega2007us14-Jul-08 4:40 
QuestionMemory Exception while saving an image Pin
DeepOceans14-Jul-08 3:59
DeepOceans14-Jul-08 3:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.