本文介紹了C# HasValue vs !=null的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我的問(wèn)題可能聽(tīng)起來(lái)有點(diǎn)愚蠢,但每次我面對(duì)它時(shí)都會(huì)讓我煩惱.有什么區(qū)別:
My question might sound a little foolish but it bugs me every time i face it. What is the difference between :
where value.HasValue
和
where value != null
HasValue 是否檢查 value
是否為空?
Does HasValue checks if value
is null?
推薦答案
他們都做同樣的事情,只是選擇一個(gè)并堅(jiān)持下去,這樣你就有了一致性.最終兩者都沒(méi)有得到任何好處.
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.
這篇關(guān)于C# HasValue vs !=null的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!