Why does >= return false when == returns true for null values?

前端 未结 8 2062
遥遥无期
遥遥无期 2020-12-07 18:17

I have two variables of type int? (or Nullable if you will). I wanted to do a greater-than-or-equal (>=) comparison on the two variables but as it turns out, this

8条回答
  •  暖寄归人
    2020-12-07 18:59

    >= operates on a numeric value; which null is not.

    You could overload the >= operator to provide what you desire on a specific type.

提交回复
热议问题