DryFish.ILib.Random 2026.1.0

dotnet add package DryFish.ILib.Random --version 2026.1.0
                    
NuGet\Install-Package DryFish.ILib.Random -Version 2026.1.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="DryFish.ILib.Random" Version="2026.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DryFish.ILib.Random" Version="2026.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DryFish.ILib.Random" />
                    
Project file
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 DryFish.ILib.Random --version 2026.1.0
                    
#r "nuget: DryFish.ILib.Random, 2026.1.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 DryFish.ILib.Random@2026.1.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=DryFish.ILib.Random&version=2026.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DryFish.ILib.Random&version=2026.1.0
                    
Install as a Cake Tool

DryFish.ILib.Random

Random generation utilities for DryFish.ILib - strings, numbers, characters, colors, dates and more.

NuGet Version NuGet Downloads License Build Status

✨ Features

  • 📝 String Array Random - Random element from user-provided array
  • 🔢 Number Generation - Integers, longs, doubles, booleans
  • 🔤 Character Generation - Letters, digits, custom ranges
  • 🎨 Color Generation - Hex colors, console colors
  • 📅 GUID Generation - Random unique identifiers
  • 📚 Collection Utilities - Random items from lists
  • 🔒 Thread-Safe - Safe for multi-threaded applications
  • Lightweight - Zero external dependencies
  • 🔧 Cross-Platform - Supports .NET 6/7/8, .NET Standard 2.0, .NET Framework 4.6.2+

📦 Installation

.NET CLI

dotnet add package DryFish.ILib.Random

Package Manager

NuGet\Install-Package DryFish.ILib.Random

PackageReference

<PackageReference Include="DryFish.ILib.Random" Version="2026.1.0" />

🚀 Quick Start

using DryFish.ILib.Random;

// User provides their own array
string[] names = { "an", "binh", "chi" };
int[] numbers = { 1, 2, 3, 4, 5 };
char[] letters = { 'A', 'B', 'C', 'D', 'E' };

// Random from user's array
string randomName = ILibRandom.IRandomFromArray(names);     // returns "binh"
int randomNumber = ILibRandom.IRandomFromArray(numbers);    // returns 3
char randomLetter = ILibRandom.IRandomFromArray(letters);   // returns 'D'

// Random numbers
int dice = ILibRandom.IRandomInt(1, 6);                     // returns 4
long bigNum = ILibRandom.IRandomLong(1000, 9999);          // returns 5432
double percent = ILibRandom.IRandomDouble(0.0, 1.0);       // returns 0.73
bool isHeads = ILibRandom.IRandomBool();                   // returns true

// Random characters
char upper = ILibRandom.IRandomUppercase();                 // returns 'X'
char lower = ILibRandom.IRandomLowercase();                 // returns 'm'
char alphabet = ILibRandom.IRandomAlphabet('A', 'Z');      // returns 'G'

// Random colors
string hexColor = ILibRandom.IRandomHexColor();             // returns "#FF5733"
string consoleColor = ILibRandom.IRandomConsoleColor();     // returns "cyan"

// Random GUID
string guid = ILibRandom.IRandomGuid();                     // returns "a1b2c3d4-..."

// Random from List
var cities = new List<string> { "Hanoi", "Saigon", "Danang" };
string city = ILibRandom.IRandomItem(cities);               // returns "Saigon"

📚 API Reference

Array Methods

Method Description Example
IRandomFromArray(string[] array) Random element from string array ILibRandom.IRandomFromArray(names)
IRandomFromArray<T>(T[] array) Random element from generic array ILibRandom.IRandomFromArray(numbers)

Number Methods

Method Description Example
IRandomInt(int min, int max) Random integer ILibRandom.IRandomInt(1, 10)
IRandomInt() Random integer (0-100) ILibRandom.IRandomInt()
IRandomLong(long min, long max) Random long ILibRandom.IRandomLong(1000, 9999)
IRandomDouble(double min, double max) Random double ILibRandom.IRandomDouble(0.5, 1.5)
IRandomBool() Random boolean ILibRandom.IRandomBool()

Character Methods

Method Description Example
IRandomChar(char min, char max) Random character ILibRandom.IRandomChar('A', 'Z')
IRandomAlphabet(char min, char max) Random letter only ILibRandom.IRandomAlphabet('A', 'Z')
IRandomUppercase() Random uppercase letter ILibRandom.IRandomUppercase()
IRandomLowercase() Random lowercase letter ILibRandom.IRandomLowercase()

Collection Methods

Method Description Example
IRandomItem<T>(IList<T> list) Random item from list ILibRandom.IRandomItem(myList)

Color Methods

Method Description Example
IRandomHexColor() Random hex color ILibRandom.IRandomHexColor()
IRandomConsoleColor() Random console color name ILibRandom.IRandomConsoleColor()

Utility Methods

Method Description Example
IRandomGuid() Random GUID string ILibRandom.IRandomGuid()

💡 Examples

Basic Usage

using DryFish.ILib.Random;

// User provides their own name array
string[] names = { "An", "Binh", "Chi", "Dung" };
string winner = ILibRandom.IRandomFromArray(names);
Console.WriteLine($"Winner: {winner}");

Random Dice Roll

int dice = ILibRandom.IRandomInt(1, 6);
Console.WriteLine($"You rolled: {dice}");

Random Password Generator

string[] chars = { "A", "B", "C", "1", "2", "3", "!", "@", "#" };
string password = "";
for (int i = 0; i < 8; i++)
{
    password += ILibRandom.IRandomFromArray(chars);
}
Console.WriteLine($"Password: {password}");

Random Color Chooser

string color = ILibRandom.IRandomConsoleColor();
Console.WriteLine($"Random color: {color}");

🔧 Requirements

  • .NET 6.0 or later
  • .NET Core 6.0+
  • .NET Framework 4.6.2+
  • .NET Standard 2.0
  • Compatible with Windows, Linux, and macOS

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

DryFish

🙏 Acknowledgments

  • Built with .NET 6/7/8 and .NET Standard 2.0
  • Thread-safe random implementation
  • Inspired by DryFish.ILib

Made with ❤️ by DryFish

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2026.1.0 89 5/31/2026