Szerkesztés

Megosztás a következőn keresztül:


RandomNumberGenerator Class

Definition

Provides functionality for generating random values.

public ref class RandomNumberGenerator abstract : IDisposable
public ref class RandomNumberGenerator abstract
public abstract class RandomNumberGenerator : IDisposable
public abstract class RandomNumberGenerator
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class RandomNumberGenerator
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class RandomNumberGenerator : IDisposable
type RandomNumberGenerator = class
    interface IDisposable
type RandomNumberGenerator = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type RandomNumberGenerator = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type RandomNumberGenerator = class
    interface IDisposable
Public MustInherit Class RandomNumberGenerator
Implements IDisposable
Public MustInherit Class RandomNumberGenerator
Inheritance
RandomNumberGenerator
Derived
Attributes
Implements

Remarks

Cryptographic random number generators create cryptographically strong random values.

Using the static members of this class is the preferred way to generate random values.

To create a random number generator, call the Create() method. This is preferred over calling the constructor of the derived class RNGCryptoServiceProvider, which is not available on all platforms.

Constructors

RandomNumberGenerator()

Initializes a new instance of RandomNumberGenerator.

Methods

Create()

Creates an instance of the default implementation of a cryptographic random number generator that can be used to generate random data.

Create(String)
Obsolete.

Creates an instance of the specified implementation of a cryptographic random number generator.

Dispose()

When overridden in a derived class, releases all resources used by the current instance of the RandomNumberGenerator class.

Dispose(Boolean)

When overridden in a derived class, releases the unmanaged resources used by the RandomNumberGenerator and optionally releases the managed resources.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Fill(Span<Byte>)

Fills a span with cryptographically strong random bytes.

GetBytes(Byte[])

When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of values.

GetBytes(Byte[], Int32, Int32)

Fills the specified byte array with a cryptographically strong random sequence of values.

GetBytes(Int32)

Creates an array of bytes with a cryptographically strong random sequence of values.

GetBytes(Span<Byte>)

Fills a span with cryptographically strong random bytes.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetHexString(Int32, Boolean)

Creates a string filled with cryptographically random hexadecimal characters.

GetHexString(Span<Char>, Boolean)

Fills a buffer with cryptographically random hexadecimal characters.

GetInt32(Int32)

Generates a random integer between 0 (inclusive) and a specified exclusive upper bound using a cryptographically strong random number generator.

GetInt32(Int32, Int32)

Generates a random integer between a specified inclusive lower bound and a specified exclusive upper bound using a cryptographically strong random number generator.

GetItems<T>(ReadOnlySpan<T>, Int32)

Creates an array populated with items chosen at random from choices.

GetItems<T>(ReadOnlySpan<T>, Span<T>)

Fills the elements of a specified span with items chosen at random from the provided set of choices.

GetNonZeroBytes(Byte[])

When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of nonzero values.

GetNonZeroBytes(Span<Byte>)

Fills a byte span with a cryptographically strong random sequence of nonzero values.

GetString(ReadOnlySpan<Char>, Int32)

Creates a string populated with characters chosen at random from choices.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Shuffle<T>(Span<T>)

Performs an in-place shuffle of a span using cryptographically random number generation.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also