从用vs2005开始,很多人在判断string类型时.喜欢用String.IsNullOrEmpty()来完成判断为""的情况.
但今天无意间发现.其中根本不包括我们潜意思中想当然有的Trim()功能,所以会认为
string.IsNullOrEmpty(" ")为true,其实是为false.
好像1个空格 !=String.Empty哦。
string AA=" ";
string.IsNullOrEmpty(A) =false
string.IsNullOrEmpty(Trim(A)) =true
Inside the method:
[code]
public static bool IsNullOrEmpty(string value)
{
if (value != null)
return (value.Length == 0);
}
return true;
[/code]