StringEnum NuGet Package

StringEnum is a base class for creating string-valued enums in .NET.

Features
- Your StringEnum interface looks similar to a regular enum
- Provides static Parse() and TryParse() methods and implicit cast to string.
- Intellisense will suggest the enum name if the class is annotated with the xml comment `<completitionlist>`.

(Works in both C# and VB)

Usage:

///<completionlist cref="HexColor"/>
class HexColor : StringEnum<HexColor>
{
public static readonly HexColor Blue = Create("#FF0000");
public static readonly HexColor Green = Create("#00FF00");
public static readonly HexColor Red = Create("#000FF");
}

// Static Parse Method
HexColor.Parse("#FF0000") // => HexColor.Red
HexColor.Parse("#ff0000", caseSensitive: false) // => HexColor.Red
HexColor.Parse("invalid") // => throws InvalidOperationException

// Static TryParse method.
HexColor.TryParse("#FF0000") // => HexColor.Red
HexColor.TryParse("#ff0000", caseSensitive: false) // => HexColor.Red
HexColor.TryParse("invalid") // => null

// Conversion from your `StringEnum` to `string`
string myString1 = HexColor.Red.ToString(); // => "#FF0000"
string myString2 = HexColor.Red; // => "#FF0000" (implicit cast).




Got any StringEnum Question?





Info

Version: 0.1.0
Author(s): Gerardo Grignoli
Last Update: Wednesday, October 23, 2019
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/gerardog/StringEnum
NuGet Url: https://www.nuget.org/packages/StringEnum


Install
Install-Package StringEnum
dotnet add package StringEnum
paket add StringEnum
StringEnum Download (Unzip the "nupkg" after downloading)



Tags



STATS

must-have-score

.3

avg-downloads-per-day

2

days-since-last-release

1856