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
Exceptions
- ArgumentNullException
Thrown when
randomis null.
Methods
Next(int)
Returns a non-negative random integer that is less than the specified maximum.
public int Next(int maxValue)
Parameters
maxValueintThe exclusive upper bound.
Returns
- int
A random integer in the range [0, maxValue).
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |