我有下面的方法,我需要检查参数是否为空或为空。
public DB Where(string field, string operat, string value, string andOr, string field2, string operat2, string value2)
{
_Where = " WHERE " + field + " " + operat + " @" + field + "1 " + andOr + " " + field2 + " " + operat2 + " @" + field2 + "2 ";
_Params.Add(field + "1", value);
_Params.Add(field2 + "2", value2);
return this;
}
Run Code Online (Sandbox Code Playgroud)
我找到了 string.IsNullOrWhiteSpace 方法,但这需要这么多代码:
if (string.IsNullOrWhiteSpace(field))
throw new ArgumentException("field Cannot be null …Run Code Online (Sandbox Code Playgroud)