构造
public class tool
{
public tool() { }
public tool IsEmpty(object obj, string paramName)
{
if (obj.IsNullOrEmpty())
{
throw Exception($"参数不能为空: {paramName}为空!");
}
if (obj.IsNullOrWhiteSpace())
{
throw new Exception($"参数不能为空: {paramName}为空!");
}
return this;//关键点
}
}
调用
string TeamsId=null,StartTime=null;
//调用判断空
new tool().IsEmpty(TeamsId, nameof(TeamsId)).IsEmpty(StartTime, nameof(StartTime));