BaseResponse response = new BaseResponse();
PropertyInfo[] properties = request.GetType().GetProperties();foreach (var item in properties)
{
if (item.GetValue(request, null) == "" || item.GetValue(request, null) == null)
{
response.IsSuccess = false;
response.Message = "所有参数都不能为空";
break;
}
}
本文介绍了一种用于检查请求参数是否为空的校验逻辑。通过获取请求对象的所有属性并逐一检查其值来确保没有空参数传入,从而避免后续处理过程中可能出现的错误。
411

被折叠的 条评论
为什么被折叠?



