Using c# Is it possible using to associate properties for each enum items?
I have used the Description Attribute to add English description to an enum
item.
You can create yet another extention method for this.
public static object Create(this MyEnum enum)
{
switch (enum)
{
case MyEnum.First:
return new { IsFirst = true, UnitType = 1}];
case MyEnum.Second:
return new ...
default:
...
}
}
then use it like so:
dynamic first = MyEnum.First.Create();
var isFirst = first.IsFirst;
but you really should consider creating a factory to create your objects.