J
jonpb
The documentation for the "is" keyword says:
An is expression evaluates to true if the provided expression is
non-null, and the provided object can be cast to the provided type
without causing an exception to be thrown.
So, given:
enum TestEnum { t1, t2 }
TestEnum te = TestEnum.t1;
int ti = (int)te;
if (te is int)
{
}
Why does the test for (te is int) fail? Is there a work around for a
function like this:
string CStr(Object arg)
{
if (arg is int)
{
}
}
other then always casting enums to ints?
Thanks
An is expression evaluates to true if the provided expression is
non-null, and the provided object can be cast to the provided type
without causing an exception to be thrown.
So, given:
enum TestEnum { t1, t2 }
TestEnum te = TestEnum.t1;
int ti = (int)te;
if (te is int)
{
}
Why does the test for (te is int) fail? Is there a work around for a
function like this:
string CStr(Object arg)
{
if (arg is int)
{
}
}
other then always casting enums to ints?
Thanks