C# HasValue vs !=null [duplicate]

2019-01-22 16:48发布

This question already has an answer here:

My question might sound a little foolish but it bugs me every time i face it. What is the difference between :

where value.HasValue

and

where value != null

Does HasValue checks if value is null?

标签: c# null
1条回答
放荡不羁爱自由
2楼-- · 2019-01-22 17:16

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.

查看更多
登录 后发表回答