This topic provides code samples for mathematical operations.
-
Rounds the decimal and returns a double, in this case 13.
myDouble = Math.Round(12.5, MidpointRounding.AwayFromZero)
-
Rounds the decimal to the nearest even number and returns a double, in this case 12.
myDouble = Math.Round(12.5, MidpointRounding.ToEven)
-
Initializes a new Random object.
rand = new Random()
-
Generates a random integer between 1 and 10.
myRandomInteger = rand.Next(1, 101)
-
Generates a random double between 1 and 50.
myRandomDouble = rand.NextDouble(1, 51)