string emptyStr = string.Empty;
IsNullOrEmpty 判断
null 返回 true
"" 返回 true
emptyStr 返回 true
" " 返回 false
IsNullOrWhiteSpace 判断
null 返回 true
"" 返回 true
emptyStr 返回 true
" " 返回 true
//IsNullOrEmpty
string emptyStr = string.Empty;
Console.WriteLine("\"\" IsEmpty 返回:" + string.IsNullOrEmpty(""));
Console.WriteLine("null IsEmpty 返回:" + string.IsNullOrEmpty(null));
Console.WriteLine("Empty IsEmpty 返回:" + string.IsNullOrEmpty(emptyStr));
Console.WriteLine("\" \" IsEmpty 返回:" + string.IsNullOrEmpty(" "));
//IsNullOrEmpty
Console.WriteLine("\"\" IsNullOrWhiteSpace 返回:" + string.IsNullOrWhiteSpace(""));
Console.WriteLine("null IsNullOrWhiteSpace 返回:" + string.IsNullOrWhiteSpace(null));
Console.WriteLine("Empty IsNullOrWhiteSpace 返回:" + string.IsNullOrWhiteSpace(emptyStr));
Console.WriteLine("\" \" IsNullOrWhiteSpace 返回:" + string.IsNullOrWhiteSpace(" "));
Console.ReadLine();