S
Steve Wilkinson
This may or may not have been asked before so forgive me if it has.
Why is an exception not thrown when a numeric value is cast to an enumerated
type which does not contain that numeric value ?
e.g.
private enum TestEnum
{
None = 0,
Value1 = 5,
Value2 = 10,
Value3 = 15
}
The following doesn't throw an exception:
TestEnum te = (TestEnum)6;
Can anyone explain why and if it is classed as behaviour by design what is
the reasoning behind this ?
Thanks
Steve
Why is an exception not thrown when a numeric value is cast to an enumerated
type which does not contain that numeric value ?
e.g.
private enum TestEnum
{
None = 0,
Value1 = 5,
Value2 = 10,
Value3 = 15
}
The following doesn't throw an exception:
TestEnum te = (TestEnum)6;
Can anyone explain why and if it is classed as behaviour by design what is
the reasoning behind this ?
Thanks
Steve