You need to surround the statement in parentheses.
if ( !myVariable is SomeType )
This line applies the NOT operator to myVariable, not the entire operator. Try:
if ( !( myVariable is SomeType ) )
Although, I will be wary of code that still checks the object for its type. You can take a look at the concept of polymorphism.
Ed S.
source share