string.IsNullOrEmpty和string.IsNullOrWhiteSpace
 本人一直使用的是string.IsNullOrEmpty方法来判断字符串是否为空.
在插件中发现另外一种写法:
            string s1 = null;
             string s2 = string.Empty;
             string s3 = "";
             string s4 = "  ";
             string s5 = "\t";
             Console.WriteLine(string.IsNullOrEmpty(s1) + "------" + string.IsNullOrWhiteSpace(s1));
             Console.WriteLine(string.IsNullOrEmpty(s2) + "------" + string.IsNullOrWhiteSpace(s2));
             Console.WriteLine(string.IsNullOrEmpty(s3) + "------" + string.IsNullOrWhiteSpace(s3));
             Console.WriteLine(string.IsNullOrEmpty(s4) + "------" + string.IsNullOrWhiteSpace(s4));
             Console.WriteLine(string.IsNullOrEmpty(s5) + "------" + string.IsNullOrWhiteSpace(s5));
             Console.ReadKey();
输出结果 :

 结论:string.IsNullOrEmpty方法无法判断空字符串和带有换行符的字符串,所以string.IsNullOrWhiteSpace方法的功能要更完善
 微软给的解释是:
                   string.IsNullOrWhiteSpace方法的性能要高,所以建议使用此方法,最后决定以后判断字符串为空都用这个方法了
  



















