Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3751610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:05:57+00:00 2026-05-19T09:05:57+00:00

Why is it that in .NET null >= null resolves as false, but null

  • 0

Why is it that in .NET

null >= null

resolves as false, but

null == null 

resolves as true?

In other words, why isn’t null >= null equivalent to null > null || null == null?

Does anyone have the official answer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:05:58+00:00Added an answer on May 19, 2026 at 9:05 am

    This behaviour is defined in the C# specification (ECMA-334) in section 14.2.7 (I have highlighted the relevant part):

    For the relational operators

    < > <= >=
    

    a lifted form of an operator exists if the operand types are both non-nullable value types and if the result type
    is bool. The lifted form is constructed by adding a single ? modifier to each operand type. The lifted
    operator produces the value false if one or both operands are null
    . Otherwise, the lifted operator unwraps
    the operands and applies the underlying operator to produce the bool result.

    In particular, this means that the usual laws of relations don’t hold; x >= y does not imply !(x < y).

    Gory details

    Some people have asked why the compiler decides that this is a lifted operator for int? in the first place. Let’s have a look. 🙂

    We start with 14.2.4, ‘Binary operator overload resolution’. This details the steps to follow.

    1. First, the user-defined operators are examined for suitability. This is done by examining the operators defined by the types on each side of >=… which raises the question of what the type of null is! The null literal actually doesn’t have any type until given one, it’s simply the “null literal”. By following the directions under 14.2.5 we discover there are no operators suitable here, since the null literal doesn’t define any operators.

    2. This step instructs us to examine the set of predefined operators for suitability. (Enums are also excluded by this section, since neither side is an enum type.) The relevant predefined operators are listed in sections 14.9.1 to 14.9.3, and they are all operators upon primitive numeric types, along with the lifted versions of these operators (note that strings operators are not included here).

    3. Finally, we must perform overload resolution using these operators and the rules in 14.4.2.

    Actually performing this resolution would be extremely tedious, but luckily there is a shortcut. Under 14.2.6 there is an informative example given of the results of overload resolution, which states:

    …consider the predefined implementations of the binary * operator:

    int operator *(int x, int y);
    uint operator *(uint x, uint y);
    long operator *(long x, long y);
    ulong operator *(ulong x, ulong y);
    void operator *(long x, ulong y);
    void operator *(ulong x, long y);
    float operator *(float x, float y);
    double operator *(double x, double y);
    decimal operator *(decimal x, decimal y);
    

    When overload resolution rules (§14.4.2) are applied to this set of operators, the effect is to select the first of
    the operators for which implicit conversions exist from the operand types.

    Since both sides are null we can immediately throw out all unlifted operators. This leaves us with the lifted numeric operators on all primitive numeric types.

    Then, using the previous information, we select the first of the operators for which an implicit conversion exists. Since the null literal is implicitly convertible to a nullable type, and a nullable type exists for int, we select the first operator from the list, which is int? >= int?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does some article or proof exist that .NET applications are immune to low level
Now that .NET v3.5 SP1 has been released (along with VS2008 SP1), we now
Is that .NET related? It appears to be a pointer of some sort, what
I know that .NET is JIT compiled to the architecture you are running on
How is it possible that .NET is finding the wrong MyType in this scenario?
I understand that .NET FileStream's Flush method only writes the current buffer to disk,
Am I able to embed the .net runtime so that .net is not required
I am aware that in .NET there are three timer types (see Comparing the
I find that the .NET event model is such that I'll often be raising
I know that the .NET framework looks for referenced DLLs in several locations Global

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.