Solved

C# Code to Get Random Number between 1 and 52

Posted on 2014-01-26
3
251 Views
Last Modified: 2014-01-26
I did this about 5 years ago, but forgot.

Thanks
0
Comment
Question by:Dovberman
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 39809963
Random random = new Random();
int randomNumber = random.Next(1, 52);
0
 
LVL 2

Assisted Solution

by:SickSkilz
SickSkilz earned 100 total points
ID: 39810005
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
 

Author Closing Comment

by:Dovberman
ID: 39810144
Thanks to both of you.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question