Consider the following Enum:
public enum MyEnum
{
TypeOneEnum0,
TypeOneEnum1,
TypeOneEnum2,
.
.
.
// From this line only TypeTwo enums are allowed,
// otherwise a runtime error will be thrown from another place
TypeTwoEnum0,
TypeTwoEnum1,
TypeTwoEnum2,
}
I also have two lists, one that holds the names of TypeOne enums, and another which holds names of TypeTwo enums.
I want to make sure at compile-time that other programmers won't add TypeOne enums below the comment that indicates that only TypeTwo enums should be inserted, and vice-versa.
While I can split it to two enums, this enum is used in so many places it will be a major headache.
This does not answer my question - It says "Is it possible to specify that a enum property can only have a range of values?" I don't need to have only a range of values, I simply want to be able to identify if two "types" are mixed in the enum definition.
What are my options?