In the following code-snippet, can the inside of the if
ever be reached, if yes, under which circumstances?
MyEnum foo = ...;
if(!Enum.IsDefined(typeof(MyEnum), foo))
{
// reachable?
}
I have a WebController which expects a MyEnum
as Parameter. This parameter is then given to a Service, with the given check. Now I wonder how that check could ever be false, given that foo
needs to be a value from MyEnum
or an ArgumentException
at an earlier point (e.g. if the user provided an illegal argument).
The code definitely uses a variable of type MyEnum
, not a string
or int
.