How can an object not be compared to null?

前端 未结 5 554
一整个雨季
一整个雨季 2020-12-06 09:07

I have an \'optional\' parameter on a method that is a KeyValuePair. I wanted an overload that passes null to the core method for this parameter, but in the core method, wh

5条回答
  •  难免孤独
    2020-12-06 09:39

    KeyValuePair is a struct and hence can't be null under any circumstances. Only a reference type can be null.

    If you're trying to catch an incorrect value you'll have to validate the Key and Value members individually.

提交回复
热议问题