[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

C# Code to Get Random Number between 1 and 52

I did this about 5 years ago, but forgot.

Thanks
0
Dovberman
Asked:
Dovberman
2 Solutions
 
Éric MoreauSenior .Net ConsultantCommented:
Random random = new Random();
int randomNumber = random.Next(1, 52);
0
 
SickSkilzCommented:
Eric above is correct EXCEPT that the 2nd parameter is an upper bound that it wont reach.  So for 1 to 52 you need that 2nd line to use
Random.Next (1,53)
0
 
DovbermanAuthor Commented:
Thanks to both of you.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now