C# Fake Enum TypeInitializationException
- by userk
I'm trying to create a class that works as a flexible enum.
I came with this idea, with 2 additional static methods that allow me to add new members to that list and get only members from that list.
public class LikeEnum
{
private static List<LikeEnum> list = new List<LikeEnum>()
{ new LikeEnum("One"), new LikeEnum("Two") };
private string value;
private LikeEnum(string value)
{
this.value = value;
}
}
Unfortunately the List list is only initialized as null so this doesn't work...
Any ideas or suggestions?