#### Archived

This topic is now archived and is closed to further replies.

# C# Question?

## Recommended Posts

Hi, How do I generate a random number between 1 and 3 using C#? Thank You

##### Share on other sites
SabreMan: Everyone start as a newbie. Shame!

DarkEldar77: Sorry, i don''t know any C#.

##### Share on other sites
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
on this forum.

##### Share on other sites
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

##### Share on other sites
in the help index change your filter to ".net framework sdk" the look up System.Random

##### Share on other sites
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.

##### Share on other sites
descriptive topic name too

##### Share on other sites

  // C# codeRandom 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.

##### Share on other sites
quote:
Paste the following into the address bar in IE:

You should probably explain the copy-paste procedure as well.

##### Share on other sites
He was, at least, polite.

##### Share on other sites
quote:
He was, at least, polite.

I take it you mean SabreMan

• ### Forum Statistics

• Total Topics
628375
• Total Posts
2982318

• 10
• 9
• 14
• 24
• 11