判断字符串是否为空的几种方法

string str = string.Empty;
if (str == "")
{ }
else { }

if (str == string.Empty)
{ }
else { }

if (str.Length == 0)//效率最高
{ }
else { }

if (string.IsNullOrEmpty(str))//可读性更强
{ }
else { }

if (string.IsNullOrWhiteSpace(str))
{ }
else { }

----------------------------------------------------------------------------
创建于2017年2月24日

整理于2017年11月27日

原文地址:https://www.cnblogs.com/kanjinxiang/p/7907827.html