How to compare nullable types?

后端 未结 8 1531
夕颜
夕颜 2021-01-31 13:32

I have a few places where I need to compare 2 (nullable) values, to see if they\'re the same.

I think there should be something in the framework to support this, but can

8条回答
  •  失恋的感觉
    2021-01-31 14:08

    I wanted to find how to compare two nullable int on C#, but I always get this link after search, so if someone needs to compare exactly two nullable int, then this can be helpful

    a.GetValueOrDefault(int.MinValue).CompareTo(b.GetValueOrDefault(long.MinValue));

提交回复
热议问题