Kees C. Bakker Kees C. Bakker - 2 months ago 5
C# Question

Why are there no 'not greater than'-style operators in C#?

We're all familiar with operators like:

a > b, a >= b //greater, greater or equal
a < b, a <= b //less, less or equal

But why is there no not greater than operator for C#?

a !> b // not greater than

Will these kind of operators ever come? Are there any languages that support these kind of operators?

It might make code more readable. Not greater than is something we use in natural language quite frequently.


Arithmetically, < means "not >=" already. If you mean the exact opposite, there's always !(a >= b) to invert the condition. This particular case is so rarely used that it's essentially pointless to waste compiler complexity for these additional operators.

The only case where "!>" and <= wouldn't be identical is when either or both operands are NaN. That, however, must usually be considered an error value way earlier already and shouldn't even make it into important decisions where values are assumed to be valid numbers. If you need it anyway, either wrap the comparison in parentheses and apply the ! unary operator to it or explicitly check both operands via IsNaN.