public static void Main(string[] args)
{
var str = "";
//空字符串的情况
// true
Console.WriteLine(string.IsNullOrEmpty(str));
// true
Console.WriteLine(string.IsNullOrWhiteSpace(str));
// 空格的情况
str = " ";
// false
Console.WriteLine(string.IsNullOrEmpty(str));
// true
Console.WriteLine(string.IsNullOrWhiteSpace(str));
Console.WriteLine("" .Equals(string.Empty));
}
string.IsNullOrWhiteSpace 还是最合适的。

被折叠的 条评论
为什么被折叠?



