Click here to Skip to main content
15,894,291 members
Home / Discussions / C#
   

C#

 
QuestionMicrosoft Office 2003 solutions with Visual Studio 2010 Pin
DaleJax18-Jun-12 8:01
DaleJax18-Jun-12 8:01 
AnswerRe: Microsoft Office 2003 solutions with Visual Studio 2010 Pin
Dave Kreskowiak8-Jun-12 8:13
mveDave Kreskowiak8-Jun-12 8:13 
GeneralRe: Microsoft Office 2003 solutions with Visual Studio 2010 Pin
DaleJax18-Jun-12 10:23
DaleJax18-Jun-12 10:23 
GeneralRe: Microsoft Office 2003 solutions with Visual Studio 2010 Pin
Dave Kreskowiak8-Jun-12 10:43
mveDave Kreskowiak8-Jun-12 10:43 
GeneralRe: Microsoft Office 2003 solutions with Visual Studio 2010 Pin
chinajingang9-Jun-12 5:41
chinajingang9-Jun-12 5:41 
AnswerRe: Microsoft Office 2003 solutions with Visual Studio 2010 Pin
Bernhard Hiller10-Jun-12 20:10
Bernhard Hiller10-Jun-12 20:10 
QuestionSeeding Random Number Generator Pin
MichCl8-Jun-12 7:40
MichCl8-Jun-12 7:40 
AnswerRe: Seeding Random Number Generator Pin
Dave Kreskowiak8-Jun-12 7:50
mveDave Kreskowiak8-Jun-12 7:50 
Your call to Next:
int randomNumber = randomNum.Next(0,1);

will always return 0 because the lower limit (0) is INCLUSIVE, meaning it will be included in the possible range of values and the upper limit (1) is EXCLUSIVE, meaning that it will NOT be included in the range of possible values.

So, since Next always return an integer (whole number) and your result set goes from 0 to 0, your code will always return 0.

To return 0 or 1, you have to change the range to:
int randomNumber = randomNum.Next(0,2);


Try reading the documentation on Random.Next(int32, int32)[^].

If you want decimal values greater than or equal to 0 and LESS THAN (NOT EQUAL TO!) 1, you'll have to call Random.Double() instead. This will, of course, return a number of type double, not int.


Oh! and your "seed" value sucks if you're looking for anything close to "true" randomness. You're limiting yourself to only 936,000 different sequences of pseudo-random numbers.

Since the default constructor of Random will initialize the generator with the value in the system clock, it has the capability of generating 4.2 billion different random number sequences.


modified 8-Jun-12 14:08pm.

GeneralRe: Seeding Random Number Generator Pin
Paul Conrad8-Jun-12 12:08
professionalPaul Conrad8-Jun-12 12:08 
AnswerRe: Seeding Random Number Generator Pin
PIEBALDconsult8-Jun-12 11:25
mvePIEBALDconsult8-Jun-12 11:25 
QuestionPBX and C# and TAPI Pin
jojoba20117-Jun-12 22:47
jojoba20117-Jun-12 22:47 
AnswerRe: PBX and C# and TAPI Pin
Dave Kreskowiak8-Jun-12 3:24
mveDave Kreskowiak8-Jun-12 3:24 
QuestionRe: PBX and C# and TAPI Pin
jojoba20118-Jun-12 4:47
jojoba20118-Jun-12 4:47 
AnswerRe: PBX and C# and TAPI Pin
Dave Kreskowiak8-Jun-12 7:45
mveDave Kreskowiak8-Jun-12 7:45 
QuestionRe: PBX and C# and TAPI Pin
jojoba20118-Jun-12 7:57
jojoba20118-Jun-12 7:57 
AnswerRe: PBX and C# and TAPI Pin
Dave Kreskowiak8-Jun-12 8:06
mveDave Kreskowiak8-Jun-12 8:06 
QuestionRe: PBX and C# and TAPI Pin
jojoba20118-Jun-12 8:16
jojoba20118-Jun-12 8:16 
AnswerRe: PBX and C# and TAPI Pin
Dave Kreskowiak8-Jun-12 10:13
mveDave Kreskowiak8-Jun-12 10:13 
QuestionRe: PBX and C# and TAPI Pin
jojoba20118-Jun-12 20:36
jojoba20118-Jun-12 20:36 
AnswerRe: PBX and C# and TAPI Pin
Dave Kreskowiak9-Jun-12 4:56
mveDave Kreskowiak9-Jun-12 4:56 
Questionsystem.web.mail do note save sentitem Pin
GinoPittaro19647-Jun-12 22:37
GinoPittaro19647-Jun-12 22:37 
AnswerRe: system.web.mail do note save sentitem Pin
egenis7-Jun-12 23:55
egenis7-Jun-12 23:55 
GeneralRe: system.web.mail do note save sentitem Pin
GinoPittaro19648-Jun-12 0:02
GinoPittaro19648-Jun-12 0:02 
GeneralRe: system.web.mail do note save sentitem Pin
egenis8-Jun-12 0:31
egenis8-Jun-12 0:31 
AnswerRe: system.web.mail do note save sentitem Pin
Bernhard Hiller8-Jun-12 3:03
Bernhard Hiller8-Jun-12 3:03 

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.