if(myVariable is SomeType)
Out of nothing but curiosity, what's the opposite of that? I want to do something like:
if(!myVariable is SomeType)
if(myVariable is not SomeType)
Neither compile.
Given that "is" is a non-searchable word in most engines, this has been a hard one to find an answer to.
Duplicate:
C# : ‘is’ keyword and checking for Not
▲ Opposite of to be or perform the function of. is not. isn't. ain't.
'So' is the opposite of not.
If you start with negative four, its opposite is going to be positive four. One way to think about it, it's going to have the same absolute value but have a different sign.
Try
if (!(myVariable is SomeType))
You need to surround the statement in parentheses.
if ( !myVariable is SomeType )
That line applies the NOT operator to myVariable, not the entire statement. Try:
if ( !( myVariable is SomeType ) )
Although, I would be wary of code that checks an object for its type anyhow. You may want to look into the concept of polymorphism.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With