RandomSelection 3.0.0
dotnet add package RandomSelection --version 3.0.0
NuGet\Install-Package RandomSelection -Version 3.0.0
<PackageReference Include="RandomSelection" Version="3.0.0" />
paket add RandomSelection --version 3.0.0
#r "nuget: RandomSelection, 3.0.0"
// 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
RandomSelection
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.
Examples
- 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();
- 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 Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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 was computed. 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. |
-
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.
Updated to .NET 6, changed to use RandomNumberGenerator, and added unit tests.