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

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

    >= only means "greater than or equal" when used in that specific well defined way. When used on a class with overloaded operators it means anything the class developer wants it to mean. When applied to a string-like class, it might mean "sorts the same or higher" or it might mean "the same length or longer".

提交回复
热议问题