Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Random Numbers in C#
To generate random numbers in C#, use the Next(minValue, MaxValue) method. The parameters are used to set the minimum and maximum values.
Next(100,200);
We have set the above method under Random() object.
Random rd = new Random(); int rand_num = rd.Next(100,200);
The following is an example −
Example
using System;
class Program {
static void Main() {
Random rd = new Random();
int rand_num = rd.Next(100,200);
Console.WriteLine(rand_num);
}
}
Output
182
Advertisements