Xyaneon.Games.Dice 2.0.1

.NET Standard 2.0
dotnet add package Xyaneon.Games.Dice --version 2.0.1
NuGet\Install-Package Xyaneon.Games.Dice -Version 2.0.1
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="Xyaneon.Games.Dice" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xyaneon.Games.Dice --version 2.0.1
#r "nuget: Xyaneon.Games.Dice, 2.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xyaneon.Games.Dice as a Cake Addin
#addin nuget:?package=Xyaneon.Games.Dice&version=2.0.1

// Install Xyaneon.Games.Dice as a Cake Tool
#tool nuget:?package=Xyaneon.Games.Dice&version=2.0.1


License NuGet Build and test Coverage Status semantic-release: conventionalcommits

Package Icon

A .NET Standard 2.0 library for dice, including standard and custom dice.



To use this library, you must first install the NuGet package for it, then add the following using statement at the top of each C# source file where you plan on using it:

using Xyaneon.Games.Dice;

Rolling standard dice

Single rolls

This library provides several built-in classes representing standard dice, including:

  • D4
  • D6
  • D8
  • D10
  • D12
  • D20

These each inherit from Dice<int>. You can just call them with an empty constructor to start using them right away. An optional seed integer can also be passed into a die's constructor if you want a repeatable pseudorandom sequence of rolled values.

After creation, you can simply call the Roll method to get a random result:

var die = new D6();

int rollResult = die.Roll(); // Can be 1, 2, 3, 4, 5 or 6.
Multiple rolls

To avoid having to call Roll multiple times, you can also supply an integer indicating how many rolls you want, then get the results as an IEnumerable<int>:

var die = new D20();

// Sample returned sequence: [6, 18, 4, 20, 1]
IEnumerable<int> rollResult = die.Roll(5);

Flipping coins

This library also provides a Coin class, which is considered to be a two-sided die. Flips are returned as CoinFlipResult enum values:

var coin = new Coin();

// Could return CoinFlipResult.Heads or CoinFlipResult.Tails.
CoinFlipResult flipResult = coin.Flip();

Custom dice

You are not restricted to standard number dice. The Die<TFace> base class is generic and can be instantiated using a custom collection of your choice representing the die's faces.

var colorDie = new Die<Color>(new Color[] {

Color rollResult = die.Roll();

Symbols conversion

A static Symbols class is also provided with constants for D6 faces, and a couple conversion methods:

  • Symbols.GetD6ValueForSymbol(char symbol)
  • Symbols.GetSymbolForD6Value(int value)

You can use these to get from a ⚃ character to a 4 or vice versa, for example.


This library is free and open-source software provided under the MIT license. Please see the LICENSE.txt file for details.

Product Versions
.NET net5.0 net5.0-windows 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
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Xyaneon.Games.Dice:

Package Downloads

A .NET Standard metapackage for card and board game functionality and components, such as dice and cards.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 65 1/24/2023
2.0.0 59 1/24/2023
1.0.0 68 1/22/2023
0.1.0 560 4/10/2020