Cenum 1.0.4

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

Cenum

Object-oriented alternative to C# enum - base for defining enumerations as classes with fields, properties and methods.

Usage

Define an enumeration by creating a partial class and decorating it with the Enumeration attribute. The class should have a public static readonly field for each value of the "enumeration".

Generated method Enumerate returns an IEnumerable<T> containing all values of the enumeration.

[Enumeration]
public partial class Number
{
    public static readonly Number One = new(1);
    public static readonly Number Two = new(2);
    public static readonly Number Three = new(3);
    
    private readonly int _value;
    
    private Number(int value) => _value = value;
    
    public override string ToString() => _value.ToString();
}


foreach (var number in Number.Enumerate())
{
    Console.WriteLine(number.ToString());
}

// Output:
// 1
// 2
// 3
There are no supported framework assets in this 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.