CustomRandomRange 1.0.0
dotnet add package CustomRandomRange --version 1.0.0
NuGet\Install-Package CustomRandomRange -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CustomRandomRange" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CustomRandomRange" Version="1.0.0" />
<PackageReference Include="CustomRandomRange" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CustomRandomRange --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CustomRandomRange, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CustomRandomRange@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CustomRandomRange&version=1.0.0
#tool nuget:?package=CustomRandomRange&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CustomRandomRange
A lightweight utility for generating pseudo-random numbers across multiple numeric types using DateTime.Ticks and Guid.
📦 Features
- Generate random values for:
intlongfloatdouble
- Range-based random generation (
min,max) - Simple static API (no instantiation required)
⚙️ Implementation Overview
The library uses:
Guid.NewGuid().GetHashCode()for standalone integer randomnessDateTime.Now.Ticksmodulo range for bounded randomness
🚀 Usage
1. Generate random integer (no range)
int value = CustomRandom.Generate();
2. Generate random integer within range
int value = CustomRandom.Generate(10, 100);
3. Generate random long
long value = CustomRandom.Generate(1000L, 10000L);
4. Generate random float
float value = CustomRandom.Generate(1.5f, 5.5f);
5. Generate random double
double value = CustomRandom.Generate(1.0, 10.0);
⚠️ Limitations
1. Not cryptographically secure
- Do not use for:
- Security tokens
- Password generation
- Cryptographic purposes
2. Poor randomness quality
DateTime.Now.Tickshas limited precision- Multiple rapid calls may produce identical values
3. Range bias issue
- Using modulo (
%) introduces non-uniform distribution
4. Float/Double precision loss
(long)(max - min)
- Truncates decimal precision → inaccurate results
🛠️ Future scope
- Replace
DateTime.TickswithRandom - Avoid modulo bias
- Use proper floating-point scaling:
return min + (rand.NextDouble() * (max - min));
📌 Summary
This utility is:
- ✔ Simple
- ✔ Lightweight
Best used for:
- Testing
- Prototyping
- Non-critical randomization
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 97 | 4/19/2026 |