I have three enums:
enum ValueType : int
{
FloatingPoint = 2,
.../...
}
enum ConstraintType : int
{
Range = 2,
.../...
}
enum Parameter : int
{
ExposureTime = F(ValueType.FloatingPoint, ConstraintType.Range, 23),
.../...
}
The problem is in the signature of F if I use:
private static int F(ValueType _V, ConstraintType _C, int _N) { ... }
I get an error (invalid arguments) for every call in the definition of Parameter, but if I use the following instead:
private static int F(int _V, int _C, int _N) { ... }
Everything is fine.
It’s not a blocking problem, but I’d like to understand why is that.
The C# spec states in section 14.3 (“Enum members”) that
As far as I can tell this is why the arguments appear to have a type of
int. It’s interesting to note that this will not result in an invalid argument error:Of course it will still result in another error because you cannot use a method call to initialize enum members as Marc says. A method call is not a constant expression, while