myAdBanner

2013年9月14日 星期六

c# 判斷字串是否為空值IsNullOrEmpty

若有一個字串為空值,例如: string a=""; string b=null; string c=string.Empty; 所以要判斷a、b、c是否為空值,可以使用IsNullOrEmpty來判斷,所以上面三個字串,其結果皆為true。 string.IsNullOrEmpty(a) = true; string.IsNullOrEmpty(b) = true; string.IsNullOrEmpty(c) = true;