In both C#/Java the operator precedence of is
respectively instanceof
leads to some ugly necessary parenthesis. For example instead of writing if (!bar instanceof Foo)
you have to write if (!(bar instanceof Foo))
.
So why did the language teams decide that !
has a higher operator precedence than is/instanceof? Admittedly in C# you can overwrite operator!
which would lead to a different result in some situations, but those situations seems exceedingly rare (and non-intuitive in any case), while the case of checking if something is not a type or subtype of something is much more likely.