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

前端 未结 8 2054
遥遥无期
遥遥无期 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:42

    What values would you expect?

    null == null true

    null >= null false

    null > null false

    null <= null false

    null < null false

    null != null false

    1 == null false

    1 >= null false

    1 > null false

    1 <= null false

    1 < null false

    1 != null true aka !(1 == null)

提交回复
热议问题