I always used Nullable<>.HasValue
because I liked the semantics. However, recently I was working on someone else's existing codebase where they used Nullable<> != null
exclusively instead.
Is there a reason to use one over the other, or is it purely preference?
int? a;
if (a.HasValue)
// ...
vs.
int? b;
if (b != null)
// ...
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…