Visual C#.Net Tutorial

Define Visual C#.Net

C# Label Control

C# TextBox Control

C# Button Control

C# RadioButton Control

C# CheckBox Control

C# CheckListBox

C# ListBox Control

C# ComboBox Control

C# LinkLabel Control

C# DateTime DataType

C# DateTimePicker

C# NumericUpDown

C# RandomNumber

C# PictureBox

C# ProgressBar

C# Timer Control

C# ToolTip

C# TabControl

C# RichTextBox

C# MessageBox

C# Menu Control

C# Toolbars

C# Dialogs Box

Random Number in C#.Net

The random number generator provided by the .NET Framework is implemented via the System.Random class. By default, the parameterless constructor of the Random() class uses the computer's internal system clock to generate its own seed value whereas the parameterized constructor can accept specific seed values from within the allowed range of Int32 integers.

Random rnd = new Random();
int num = rnd.Next(); // return a positive integer number
int num = rnd.Next(50); // return a positive number less than 50
int month = rnd.Next(1, 13); // return a positive number between 1 and 12
int num = rnd.NextDouble(); // return decimal number between 0 and 1