This library is available on NuGet: https://www.nuget.org/packages/EnumUtils/ Use the following command to install EnumUtils using NuGet package manager console:
PM> Install-Package EnumUtils
You can use this library in any .Net project which is compatible to .Net Framework 4.0+ and .Net Standard 1.0+.
The unit tests shipped along with this library show nicely all the helper methods you can use. To give an impression, here a selection of provided methods:
bool isEnum = EnumHelper.IsEnum<Weekday>();
IEnumerable<Weekday> weekdays = EnumHelper.GetValues<Weekday>();
string weekday = EnumHelper.GetName(Weekday.Tue);
Weekday weekday = EnumHelper.Parse<Weekday>("Thu");
Weekday weekday = EnumHelper.TryParse<Weekday>("Thu");
Weekday weekday = EnumHelper.Cast(value: 1, defaultValue: Weekday.Mon);
Contributors welcome! If you find a bug or you want to propose a new feature, feel free to do so by opening a new issue on github.com.
This project is Copyright © 2018 Thomas Galliker. Free for non-commercial use. For commercial use please contact the author.