Redpoint.StringEnum 2026.1034.271

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Redpoint.StringEnum --version 2026.1034.271
                    
NuGet\Install-Package Redpoint.StringEnum -Version 2026.1034.271
                    
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="Redpoint.StringEnum" Version="2026.1034.271" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Redpoint.StringEnum" Version="2026.1034.271" />
                    
Directory.Packages.props
<PackageReference Include="Redpoint.StringEnum" />
                    
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 Redpoint.StringEnum --version 2026.1034.271
                    
#r "nuget: Redpoint.StringEnum, 2026.1034.271"
                    
#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 Redpoint.StringEnum@2026.1034.271
                    
#: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=Redpoint.StringEnum&version=2026.1034.271
                    
Install as a Cake Addin
#tool nuget:?package=Redpoint.StringEnum&version=2026.1034.271
                    
Install as a Cake Tool

Redpoint.StringEnum

This library provides an API for defining and using string-backed enumeration types. These are useful when used with databases, where storing string values for enumerations improves forward and backward compatibility (unlike storing numeric values).

Defining a string-backed enumeration type

You can create a string-backed enumeration, by defining a class like so:

class Example : StringEnum<Example>
{
    public static readonly StringEnumValue<Example> FirstValue = Create("first-value");

    public static readonly StringEnumValue<Example> SecondValue = Create("second-value");

    public static readonly StringEnumValue<Example> ThirdValue = Create("third-value");

    // ...
}

The string values that represent the enumeration are case-and-byte sensitive (ordinal comparison). You can not create enumeration values from a null string; ArgumentNullException will be thrown if you pass a null value to Create.

Defining additional enumeration values at runtime

There is currently no API for defining additional enumeration values at runtime; the possible enumeration values are lazy-loaded once by looking at the static fields and static properties of the class that inherits from StringEnum<T> (via the T type parameter). Both public and non-public fields/properties are included.

This library is both trim and AOT-compatible, as it uses [DynamicallyAccessedMembers] to ensure the fields and properties of the enumeration type are available at runtime for reflection.

Static usage of values

In most code, you'll simply use the static readonly fields you've defined, such as Example.FirstValue. All instances of the value - even those from parsing - are guaranteed to be reference and value equal.

Parsing known values from strings

To parse a value that is known to be valid from a string, you can use Example.Parse or StringEnumValue<Example>.Parse:

var value = Example.Parse("first-value");
var value2 = StringEnumValue<Example>.Parse("second-value");

If the value is not valid when calling Parse, StringEnumParseException will be thrown. You should use TryParse (see below) if the value is potentially invalid.

If you pass a null value to Parse, ArgumentNullException will be thrown.

Parsing potentially invalid string values

If you're unsure whether a string is a valid enumeration value, you can use Example.TryParse or StringEnumValue<Example>.TryParse:

var isValid = Example.TryParse("...", out var value);
var isValid2 = StringEnumValue<Example>.TryParse("...", out var value2);

If you pass a null value to TryParse, ArgumentNullException will be thrown.

Parsing strings to runtime-based enumeration types

If you don't know the type of the string enumeration you want to parse into at compile time, you can use DynamicStringEnumValue.TryParse to parse any string value into an instance of StringEnumValue<T> by passing the StringEnumValue<T> type as the first parameter, like so:

var type = typeof(StringEnumValue<Example>);
var isValid = DynamicStringEnumValue.TryParse(type, "...", out var value);

You can use DynamicStringEnumValue.IsStringEnumValueType to check if type is a constructed generic type of StringEnumValue<T>. The APIs provided by DynamicStringEnumValue are primarily intended to be used with database serialization and deserialization, where the concrete types of values are not known at the point of deserialization.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Redpoint.StringEnum:

Package Downloads
Redpoint.CloudFramework

A framework for building ASP.NET Core applications on top of Google Cloud Firestore in Datastore mode. Not only does this framework provide a model-based API for interacting with Google Cloud Firestore, it contains useful implementations of things like database migrations, distributed locks, geographic indexes and sharded counters.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.1044.875 0 2/13/2026
2026.1044.318 0 2/13/2026
2026.1044.264 0 2/13/2026
2026.1044.191 0 2/13/2026
2026.1044.153 0 2/13/2026
2026.1043.209 67 2/12/2026
2026.1041.745 73 2/10/2026
2026.1041.738 77 2/10/2026
2026.1041.302 72 2/10/2026
2026.1041.163 74 2/10/2026
2026.1041.35 74 2/10/2026
2026.1037.817 84 2/6/2026
2026.1035.684 94 2/4/2026
2026.1035.201 104 2/4/2026
2026.1034.271 97 2/3/2026
2026.1022.253 107 1/22/2026
2026.1022.226 100 1/22/2026
2026.1022.115 102 1/22/2026
2026.1020.299 102 1/20/2026
2026.1020.118 101 1/20/2026
Loading failed