Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Either this is a typo and you meant "==" not "&lt;=" or you misunderstand how nulls work.</p> <p>In almost all languages (including c#) the only default legal operation on null is to check if something else is equal to it (in .Net == is by default reference equality).</p> <p>&lt;= and >= are not meaningful (as they would have very strange behaviour if they did)</p> <p>Some languages (SQL being possibly the most well known) disallow the use of 'standard' equality operators to make this even more clear. in SQL null == null is NOT true, and a compliant server will refuse queries where you attempt to do this via a literal.</p> <p>C# takes the same route as it's heritage (C style imperative languages) where the test for a null value is based on testing that the bits in it are zero (things get somewhat more complex but fundamentally that's what is happening). As such only reference types can truly be null (<code>Nullable&lt;T&gt;</code> has a lot of magic behind the scenes to make it look like it is but actually under the hood it <em>isn't null</em>). This means that the reference equality semantics follow nicely into null semantics, thus the == null is allowed.</p> <p>Other languages implement null in a different fashion (for example SQL where anything can be made null thus the 'nullness' of something must be stored outside of it (much like Nullable). This means that the conventional use of equality need not be the primary concern and null can be truly special rather than a special case of certain types. For further information on the specialness of null take a look at <a href="https://stackoverflow.com/questions/75267/in-how-many-languages-is-null-not-equal-to-anything-not-even-null/75314#75314">This question has a list of such languages</a></p> <p>Most reference types do not define a >= or &lt;= operator so there is little problem in practice with the disconnect between == and &lt;= (where normally if something is true for == it would be true for &lt;= and >= as well).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload