Is it possible to specify that a enum property can only have a range of values?
enum Type
{
None,
One,
Two,
Three
}
class Object
{
[Allo
You could do a workaround like this:
static MyEnumType[] allowedEnumTypes = {MyEnumType.One, MyEnumType.Two};
MyEnumType _myEnumObject = allowedEnumTypes.First();
MyEnumType MyEnumObject
{
get
{
return _myEnumObject;
}
set
{
if(!allowedEnumTypes.Any (et => et == value))
{
throw new Exception("Enum value not allowed.");
}
_myEnumObject = value;
}
}