C# HasValue vs !=null

C#Null

C# Problem Overview


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# Solutions


Solution 1 - C#

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionoimitroView Question on Stackoverflow
Solution 1 - C#DerekView Answer on Stackoverflow