1

I have a validation code as follows:

 if ((Info.LENDER_MAIL_STATE == "") || (Info.LENDER_MAIL_CITY == "") || (Info.LENDER_NAME == "") || (Info.LENDER_MAIL_ZIPCODE == 0) || (Info.LENDER_NAME_ID == 0) || (Info.LENDER_TYPE_CODE == "") || (Info.RECORD_ID_CODE == "") || (Info.RECORD_TYPE == "") || (Info.PORPERTY_FIPSCODE == 0) || (Info.RECORDING_PAGE_NUMBER == 0) || (Info.RECORD_ID_CODE == "") || (Info.RECORDING_BOOK_NUMBER == "") || (Info.CONCRNT_MTG_LOAN_TYPE == "") || (Info.DTBORROWER == null) || (Info.RECORDING_DATE == DateTime.MinValue) || (Info.PROPERTY_STATE == "") || (Info.PROPERTY_COUNTY == "") || (Info.PROPERTY_CITY == "") || (Info.PROPERTY_STREET_ADDRESS == "") || (Info.PROPERTY_ZIP == 0) || (Info.DOC_TYPECODE == ""))
            {
                return false;
            }

In this code any of the value is empty it will return false. I need to find out which value is null. Please help. We can achieve this by if else(individual check) that I know, but i need to know the value using this if itself

4

4 回答 4

1

如果要检查特定变量的值,则必须使用单独的 if else 语句。可能没有办法解决这个问题。

虽然您可以使用调试器并单独检查它,但我猜对于不同的输入可能会有不同的结果

于 2013-10-09T04:38:09.083 回答
1

您可以重新排列代码,例如:

if ((Info.LENDER_MAIL_STATE == "") ||
    (Info.LENDER_MAIL_CITY == "") ||
    (Info.LENDER_NAME == "") || 
    (Info.LENDER_MAIL_ZIPCODE == 0) ||
    (Info.LENDER_NAME_ID == 0) ||
    (Info.LENDER_TYPE_CODE == "") ||
    (Info.RECORD_ID_CODE == "") ||
    (Info.RECORD_TYPE == "") ||
    (Info.PORPERTY_FIPSCODE == 0)
   .....
{
      return false;
}

这将允许您进入调试器。

使用else-if构造没有错。性能将是相同的,而且这种格式更适合添加评论。

ps 我们的日子string.IsNullOrWhiteSpace(Info.LENDER_MAIL_STATE)是检查字符串字段的推荐功能。

于 2013-10-09T04:38:37.920 回答
0

== ""您是通过调试相同的值而不是检查每个值来找出哪个值为空的最佳人选string.IsNullOrEmpty(Info.LENDER_MAIL_STATE)Info == null还需要检查

如果您想通过代码查找哪个值为空,您需要单独检查每个字段if statement是您可以使用的。

于 2013-10-09T04:40:08.743 回答
0

哎呀。对于您的要求,没有简单的解决方法。

顺便说一句,看看一个 SO 线程which-condition-is-true-in-an-if-statement

我的建议与客户端验证相关的任何方式,可能是 jquery,因为您和您的团队在同一方面足够强大。

快乐的编码日。干杯伙计。

于 2013-11-04T11:09:26.733 回答