I have defined a custom enum
DescriptionAttribute
(see my previous question: Multiple enum descriptions)
public class DescriptionWithValueAttribute : DescriptionAttribute
{
public Decimal Value { get; private set; }
public DescriptionWithValueAttribute(String description, Decimal value)
: base(description)
{
Value = value;
}
}
My enum
looks like this:
public enum DeviceType
{
[DescriptionWithValueAttribute("Set Top Box", 9.95m)]
Stb = 1,
}
I get the following error when compiling:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
I have also tried: [DescriptionWithValueAttribute("Set Top Box", (Decimal)9.95)]
Any ideas?