89

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?

oimitro
  • 1,466
  • 4
  • 14
  • 22
  • 3
    http://stackoverflow.com/questions/5233882/is-there-any-difference-between-mynullablelong-hasvalue-and-mynullablelong-nu – 0xAX Jul 22 '13 at 09:27

1 Answers1

106

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.

Amitd
  • 4,769
  • 8
  • 56
  • 82
Derek
  • 8,300
  • 12
  • 56
  • 88