Docsity

Introduction to Random Numbers - C Sharp Programming - Lecture Slides, Slides of C Sharp Programming

Partial preview of the text

Download Introduction to Random Numbers - C Sharp Programming - Lecture Slides and more Slides C Sharp Programming in PDF only on Docsity!

Introduction to Random

Numbers

Lecture Overview

 Introduce the System.Random class

Using the Random Class (1)

 Create an instance of the Random class with a random seed value

Random CurrentRandom = new Random()  Create an instance of the Random class with a fixed seed value (The same sequence of numbers will always be generated

Random CurrentRandom = new Random(10)

Using the Random Class (2)

Next returns a random integer  It can also return a value within a range by passing the minimum and maximum value as arguments I = CurrentRandom.Next() I = CurrentRandom.Next(1, 10)NextDouble returns a double between 0 and 1 J = CurrentRandom.NextDouble()