IsNullOrWhiteSpace可以判断字符串是否为null,""," ","\n","\t"
string str1 = string.Empty;
if (string.IsNullOrWhiteSpace(str1))
{
Console.WriteLine("str1 is empty"); ;
}
string str2 = "";
if (string.IsNullOrWhiteSpace(str2))
{
Console.WriteLine("str2 is empty"); ;
}
string str3 = null;
if (string.IsNullOrWhiteSpace(str3))
{
Console.WriteLine("str3 is empty"); ;
}
string str4 = " ";
if (string.IsNullOrWhiteSpace(str4))
{
Console.WriteLine("str4 is empty"); ;
}
string str5 = "\n";
if (string.IsNullOrWhiteSpace(str5))
{
Console.WriteLine("str5 is empty"); ;
}
string str6 = "\t";
if (string.IsNullOrWhiteSpace(str6))
{
Console.WriteLine("str6 is empty"); ;
}