Table of Contents

SystemRandomAdapter Class

Definition

Namespace
Bodu.Collections.Generic.Extensions
Assembly
Bodu.Core.dll
Package
Bodu.Core 1.0.1
Source
SystemRandomAdapter.cs

Adapts a Random instance to the IRandomGenerator interface.

public sealed class SystemRandomAdapter : IRandomGenerator
Inheritance
SystemRandomAdapter
Implements
Inherited Members
Extension Methods

Remarks

This adapter allows Random to be used wherever code depends on the IRandomGenerator abstraction, enabling straightforward substitution for testing or alternative generators.

Constructors

SystemRandomAdapter()

Initializes a new instance of the SystemRandomAdapter class with a default Random instance.

public SystemRandomAdapter()

Remarks

The Random default constructor is used, which seeds the generator from the system clock.

SystemRandomAdapter(Random)

Initializes a new instance of the SystemRandomAdapter class with the specified Random instance.

public SystemRandomAdapter(Random random)

Parameters

random Random

The Random instance to wrap. Must not be null.

Exceptions

ArgumentNullException

Thrown when random is null.

Methods

Next(int)

Returns a non-negative random integer that is less than the specified maximum.

public int Next(int maxValue)

Parameters

maxValue int

The exclusive upper bound.

Returns

int

A random integer in the range [0, maxValue).

Applies to

ProductVersions
.NET8, 10