StringEnum 0.1.0

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)

Install-Package StringEnum -Version 0.1.0
dotnet add package StringEnum --version 0.1.0
<PackageReference Include="StringEnum" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StringEnum --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

See docs on GitHub

See docs on GitHub

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.0 56 10/23/2019
0.0.2 36 10/21/2019