O
O.B.
Why doesn't the cast to "4" in the statement below not throw an
exception?
private enum TestEnum
{
Zero,
One,
Two,
Three
}
[Test]
public void WeirdEnumBehavior()
{
TestEnum e = TestEnum.One;
Console.WriteLine(e.ToString()); // Prints "One"
e = (TestEnum) 4; // Why doesn't this throw an exception?
Console.WriteLine(e.ToString()); // Prints "4"
}
exception?
private enum TestEnum
{
Zero,
One,
Two,
Three
}
[Test]
public void WeirdEnumBehavior()
{
TestEnum e = TestEnum.One;
Console.WriteLine(e.ToString()); // Prints "One"
e = (TestEnum) 4; // Why doesn't this throw an exception?
Console.WriteLine(e.ToString()); // Prints "4"
}