Skip to content

Thinking more…

Just thinking more…

Day: January 25, 2008

Posted on 2008/01/25

String.IsNullOrEmpty

長見識,原來 .Net framework 2 之後為 String 多提供了一個方便的 Method:IsNullOrEmpty

所以以後可以不用寫成這樣了:

string s;
if( s!=null && s!=String.Empty )
{
// do something
}

補充:不過有文章(DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !! – @ Head)指出這方法其實有可能會丟出 Null exception.

January 2008
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  
« Dec   Feb »

站內搜索

Categories

  • .Net
  • Android
  • Blog
  • Boo
  • C/C++
  • Cook
  • Linux 及其相關
  • Lyrics
  • Python
  • Visual FoxPro
  • Wine品嚐美酒
  • 亂亂逛
  • 個人新聞台
  • 理財
  • 資訊相關Idea與筆記
  • 雜記,隨筆
  • 電影流水帳
Privacy Policy Proudly powered by WordPress