string.IsNullOrWhiteSpace
测试环境:https://try.dot.net/
Console.WriteLine(string.IsNullOrWhiteSpace("")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace(" ")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace(" ")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace(" ")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace(" ")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace(" ")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace(null)); --> True
Console.WriteLine(string.IsNullOrWhiteSpace("\0")); --> False \0 空字符 所以如果输入字符串中含有 \0 这样的单独串,使用 string.IsNullOrWhiteSpace 是应该注意
Console.WriteLine(string.IsNullOrWhiteSpace("\t")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace("\v")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace("\r")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace("\n")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace("\f")); --> True
Console.WriteLine(string.IsNullOrWhiteSpace("\a")); --> False \a 感叹号
Console.WriteLine(string.IsNullOrWhiteSpace("\b")); --> False \b 退格
Console.WriteLine("123\0"+'d'); --> 123 d
Console.WriteLine(("123\0"+'d').Length); --> 5
Console.WriteLine("\\0"+'d'); --> \0d
Console.WriteLine(@"\0"+'d'); --> \0d