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

C#

 
QuestionHmmm why won't this work? Pin
mfkr2-Jun-07 17:58
mfkr2-Jun-07 17:58 
AnswerRe: Hmmm why won't this work? Pin
Christian Graus2-Jun-07 19:07
protectorChristian Graus2-Jun-07 19:07 
GeneralRe: Hmmm why won't this work? Pin
mfkr2-Jun-07 19:17
mfkr2-Jun-07 19:17 
GeneralRe: Hmmm why won't this work? Pin
Christian Graus2-Jun-07 19:22
protectorChristian Graus2-Jun-07 19:22 
AnswerRe: Hmmm why won't this work? Pin
Robert Surtees2-Jun-07 19:24
Robert Surtees2-Jun-07 19:24 
GeneralRe: Hmmm why won't this work? Pin
mfkr2-Jun-07 19:32
mfkr2-Jun-07 19:32 
GeneralRe: Hmmm why won't this work? Pin
Christian Graus2-Jun-07 20:33
protectorChristian Graus2-Jun-07 20:33 
GeneralRe: Hmmm why won't this work? Pin
Dave Kreskowiak3-Jun-07 5:07
mveDave Kreskowiak3-Jun-07 5:07 
No, not odd. Understand how a Random Number Generator works. There's no such thing as a truely random number in a computer. They can't come up with a number out of thin air. Even humans can't do this reliably.

The RNG is a smallish piece of code that takes a starting number (a seed) and puts it through a complex calculations to arive at a new number. The next pseudo-random number takes the previous one and runs it through the same math to arrive at a new number, and so on, and so on.

This generates a string of REPEATABLE pseudo-random numbers, given any seed value.

As the previous poster said, if you don't give a seed value when you create your Random object, the timer value is used. All of your objects are creating their own Random object, but they're all seeded with the exact same value! There result will be all of of those Random objects each generating the exact same string of numbers!

Typically, you'd create a static Random somewhere, much like a "global variable", that all of your code can get to. That way, you only have one source of random numbers, which will give you a closer approximation of "random" acrossed your code than having multiple sources.


A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


QuestionCasting generic parameters to int Pin
Jack Valmadre2-Jun-07 15:19
Jack Valmadre2-Jun-07 15:19 
AnswerRe: Casting generic parameters to int Pin
mikker_1232-Jun-07 16:29
mikker_1232-Jun-07 16:29 
GeneralRe: Casting generic parameters to int Pin
Jack Valmadre2-Jun-07 17:27
Jack Valmadre2-Jun-07 17:27 
GeneralRe: Casting generic parameters to int Pin
Daniel Grunwald3-Jun-07 2:13
Daniel Grunwald3-Jun-07 2:13 
GeneralRe: Casting generic parameters to int Pin
mikker_1233-Jun-07 4:37
mikker_1233-Jun-07 4:37 
GeneralRe: Casting generic parameters to int Pin
Jack Valmadre3-Jun-07 10:34
Jack Valmadre3-Jun-07 10:34 
QuestionGetting to the encapsulated class within a ServiceHost object? Pin
LongRange.Shooter2-Jun-07 11:36
LongRange.Shooter2-Jun-07 11:36 
QuestionHow can you adjust the maximum window size for Word, IE, Notepad, etc.??? Pin
RedPocket2-Jun-07 8:11
RedPocket2-Jun-07 8:11 
QuestionAutomatically adding dll file to publish without reference Pin
jayrooney072-Jun-07 5:56
jayrooney072-Jun-07 5:56 
AnswerRe: Automatically adding dll file to publish without reference Pin
mikker_1232-Jun-07 16:23
mikker_1232-Jun-07 16:23 
GeneralRe: Automatically adding dll file to publish without reference Pin
jayrooney073-Jun-07 22:36
jayrooney073-Jun-07 22:36 
QuestionDoking question? Pin
Khoramdin2-Jun-07 4:51
Khoramdin2-Jun-07 4:51 
AnswerRe: Doking question? Pin
MatrixCoder2-Jun-07 13:08
MatrixCoder2-Jun-07 13:08 
QuestionAdding a A-record to Windows 2003 DNS Pin
Bigbirddk2-Jun-07 2:08
Bigbirddk2-Jun-07 2:08 
AnswerRe: Adding a A-record to Windows 2003 DNS Pin
Expert Coming2-Jun-07 18:03
Expert Coming2-Jun-07 18:03 
QuestionCreate Object Form Pin
hosam Taji2-Jun-07 2:03
hosam Taji2-Jun-07 2:03 
AnswerRe: Create Object Form Pin
Christian Graus2-Jun-07 2:06
protectorChristian Graus2-Jun-07 2:06 

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.