hasvalue vs !=null

Which is preferred: Nullable<T>.HasValue or Nullable<T> != null?

The compiler replaces null comparisons with a call to HasValue, so there is no real difference. Just do whichever is more readable/makes more sense to you and your colleagues.

 

posted @ 2019-05-07 18:48  ChuckLu  阅读(647)  评论(0编辑  收藏  举报