Professional Documents
Culture Documents
NET | Webucator
To generate random numbers in a .Net application, we use the framework class "Random". Random is
in the mscorlib library so there is no need to bring any additional namespaces into scope. The
"Random" class provides ve methods used to generate various types of random number.
1. To begin, we Instantiate the Random Class. The class has two constructor overloads. One is the
default constructor (receives no parameters) which uses a time-dependent default seed value to
initialize the class. The second constructor receives an Int32 seed value which is used to initialize
the class.
C#
VB.Net
https://www.webucator.com/how-to/how-generate-random-numbers-net.cfm 1/6
5/6/2020 How to Generate Random Numbers in .NET | Webucator
2. Next we declare some variables to hold the results of the various method calls.
C#
VB.Net
VB.Net
https://www.webucator.com/how-to/how-generate-random-numbers-net.cfm 2/6
5/6/2020 How to Generate Random Numbers in .NET | Webucator
4. Be aware the Random class is a "psuedo random number generator". In other words, it is not truly
random. The "randomness" does, however, meet certain statistical requirements for random
numbers.
About Webucator
Webucator provides instructor-led training to students throughout the US and Canada. We have
trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft
ASP.NET, Microsoft O ce, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and
(https://www.webucator.com/course/catalog.cfm).
Microsoft Training(https://www.webucator.com/microsoft-training/index.cfm)
Database Training
https://www.webucator.com/how-to/how-generate-random-numbers-net.cfm 3/6
5/6/2020 How to Generate Random Numbers in .NET | Webucator
(https://www.webucator.com/database-training/index.cfm)
Java Training(https://www.webucator.com/java-training/index.cfm)
Adobe Training(https://www.webucator.com/adobe-training/index.cfm)
Programming Training(https://www.webucator.com/programming-training/index.cfm)
Cloud Training(https://www.webucator.com/cloud-training/index.cfm)
Webucator provides instructor-led online and onsite training. Check out our complete course catalog
(https://www.webucator.com/course/catalog.cfm).
ASP.NET Courses(https://www.webucator.com/microsoft-training/aspnet-training.cfm)
https://www.webucator.com/how-to/how-generate-random-numbers-net.cfm 4/6
5/6/2020 How to Generate Random Numbers in .NET | Webucator
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
Self-paced (https://www.webucator.com/self-paced-training/index.cfm)
Testimonials (https://www.webucator.com/about-us/testimonials.cfm)
https://www.webucator.com/how-to/how-generate-random-numbers-net.cfm 5/6
5/6/2020 How to Generate Random Numbers in .NET | Webucator
Company (https://www.webucator.com/about-us/company.cfm)
(https://www.facebook.com/webucator)
(https://www.linkedin.com/companies/webucato
(https://twitter.com/webucator)
(mailto:sales@webucator.com)
https://www.webucator.com/how-to/how-generate-random-numbers-net.cfm 6/6