RandomSelection 3.0.0

.NET 6.0
dotnet add package RandomSelection --version 3.0.0
NuGet\Install-Package RandomSelection -Version 3.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="RandomSelection" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RandomSelection --version 3.0.0
#r "nuget: RandomSelection, 3.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.
// Install RandomSelection as a Cake Addin
#addin nuget:?package=RandomSelection&version=3.0.0

// Install RandomSelection as a Cake Tool
#tool nuget:?package=RandomSelection&version=3.0.0


The inspiration for this library came from watching people who were entered into supposed random prize drawings win multiple times while others were consistently not picked. RandomSelection is designed to take in entries, with the option to give some entries a higher chance at being selected, and then return one or more selectees. It utilizes System.Security.Cryptography to ensure a higher quality random number is used for shuffling the data and selecting winners.


  1. Create an instance of the Selector class, add two items representing employees and then selects one employee at random.
var selector = new Selector<string>();
selector.TryAddItem("m0392", "Doe, John", 1); 
selector.TryAddItem("m0392", "Moe, Jane", 1); 
var winner = selector.RandomSelect();
  1. Create an instance of the Selector class, add five items where the third entry has two more entries than the others. Then two winners are selected
var selector = new Selector<string>();
selector.TryAddItem("jen", "jen", 1); 
selector.TryAddItem("michael", "michael", 1); 
selector.TryAddItem("staci", "staci", 3); 
selector.TryAddItem("dave", "dave", 1); 
selector.TryAddItem("leslie", "leslie", 1); 

var winners = selector.RandomSelect(2);
Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net6.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
3.0.0 174 11/27/2022
2.0.1 350 1/2/2021
2.0.0 463 11/7/2019

Updated to .NET 6, changed to use RandomNumberGenerator, and added unit tests.