Name

Random

Synopsis

This class encapsulates a pseudorandom number (one chosen from a list of pregenerated numbers, but that is statistically random). After creating an instance of this class, use the Next(), NextDouble(), or NextBytes() methods to return random information. NextDouble() returns a fraction value between 0.0 and 1.0, while Next() returns an integer between 0 and the maximum bound that you specify. NextBytes() fills a supplied array of bytes with random numbers.

When creating a Random object, you supply a seed value to the constructor, which determines the place on the list from where the random number is drawn. If you supply the same seed value to multiple Random instances, you will receive the same random number. Computers are incapable of generating truly random numbers, and Random should not be used for cryptographic algorithms. For a cryptographically strong random number generator, see the System.Security.Cryptography.RandomNumberGenerator in the .NET Framework SDK Documentation.

Public Class Random
                  ' Public Constructors
   Public Sub New() 
   Public Sub New( ByVal Seed As Integer) 
' Public Instance Methods
   Overridable Public Function Next() As Integer  
   Overridable Public Function Next(
        ByVal maxValue As Integer) As Integer  
   Overridable Public Function Next(ByVal minValue As Integer, 
        ByVal maxValue As Integer) As Integer  
   Overridable Public Sub NextBytes( ByVal buffer As Byte()) 
   Overridable Public Function NextDouble() As Double  
' Protected Instance Methods Overridable ...

Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.