C # HasValue vs! = null

我的问题可能听起来有点愚蠢,但是每次我面对它的时候它都困扰着我。 两者的区别是什么:

where value.HasValue

还有

where value != null

HasValue 是否检查 value是否为空?

73921 次浏览

They both do the same thing, just pick one and stick with it so that you have consistency. There is nothing to gain by using either in the end.