Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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