Skip to main content
gamedev.net
🔒 Locked

C# Question?

Started by DarkEldar77 10 replies 1.4k views
Original Post
DarkEldar77
DarkEldar77
Hi, How do I generate a random number between 1 and 3 using C#? Thank You
Visit My C++ Programming Site:http://darkeldar77.tripod.com/cpp.html
SabreMan
SabreMan
Please go away.
al_le
al_le
SabreMan: Everyone start as a newbie. Shame!

DarkEldar77: Sorry, i don''t know any C#.
darookie
darookie
quote:
Original post by al_le
SabreMan: Everyone start as a newbie. Shame!


Everyone start as a newbie: agreed. But there was a time when
newbies used their own brain instead of asking trivial questions
on this forum.
Arild Fines
Arild Fines
Paste the following into the address bar in IE: ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemRandomClassTopic.htm



"The fact that a believer is happier than a skeptic is no more to the point than the fact that a drunken man is happier than a sober one." -- George Bernhard Shaw
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
SabreMan
SabreMan
quote:
Original post by al_le
SabreMan: Everyone start as a newbie. Shame!

There is only one integral between 1 and 3, which means either the OP was being deliberately stupid, or that the problem is wildly under-specified (such as, he meant 1 to 3 inclusive, or he wants FP with double precision, or some such, any of which can be answered in 10 seconds flat by reading the the manual). My initial reaction was that it was a trick question (hence my initial response), but looking at his posting history I can see he consistently under-specifies problems.
civguy
civguy
descriptive topic name too
daerid
daerid

  
// C# code

Random rnd = new Random();
Int32 number = rnd.Next(1,4);
// Parameters

// minValue: The lower bound of the random number returned.

// maxValue: The upper bound of the random number returned. maxValue must be greater than or equal to minValue.

daerid@gmail.com
Shannon Barber
Shannon Barber
He was, at least, polite.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Qw3r7yU10p!
Qw3r7yU10p!
quote:
He was, at least, polite.


I take it you mean SabreMan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.