判断字符串为空

来源:互联网 发布:网络教育毕业考试难吗 编辑:程序博客网 时间:2024/05/20 18:47

string.IsNullOrEmpty(),在VS2005的代码分析其中是建议用这个方法.

Dot Net 2.0 中的这个方法的伪代码:
public static bool IsNullOrEmpty(string value)
{
if (value != null)
{
return (value.Length == 0);
}
return true;
}

大概有三种方法判断string为空:
1.str.Lenght == 0
2.str == string.Empty
3.str == ""

原创粉丝点击