0

这是我的问题:我想创建一个程序来检查 ATM 中的错误,并将其与我的数据库中保存的数据进行比较,以获得每台机器的错误状态(已解决、未解决、新)的 SMS。该程序已完成并且工作正常,但崩溃并且在恢复 - 方法中的条件后CompareErrs停止工作。正如它现在假设的那样,它返回与新错误相同的已解决错误。这是功能:-请帮助解决条件:S

   private object[] CompareErrs(string MachineErr, string DBErr)        
    {
        #region CompareErrs
        object[] ToReturn = new object[2];

        string Errs_Solved = "";
        string Errs_UnSolved = "";
        string Errs_New = "";

        string[] MachineErrSplit = MachineErr.Split(' ');
        for (int i = 0; i < MachineErrSplit.Length; i++)
        {
            string Seperator = " ";
            //if (i == MachineErrSplit.Length - 1)
            //    Seperator = "";

            if (DBErr.Contains(MachineErrSplit[i]))
            {
                Errs_UnSolved += MachineErrSplit[i] + Seperator;
            }
            else //if (MachineErrSplit[i].Contains(DBErr))
            {
                Errs_Solved += MachineErrSplit[i] + Seperator;
            }

            if (!DBErr.Contains(MachineErrSplit[i]))
            {
                Errs_New += MachineErrSplit[i] + Seperator;
            }
        }

        ToReturn[0] = new string[3] { Errs_Solved, Errs_UnSolved, Errs_New };
        ToReturn[1] = MachineErr;
        return ToReturn;

        #endregion
    }
4

1 回答 1

1
else //if (MachineErrSplit[i].Contains(DBErr))
{
     Errs_Solved += MachineErrSplit[i] + Seperator;
}

if (!DBErr.Contains(MachineErrSplit[i]))
{
     Errs_New += MachineErrSplit[i] + Seperator;
}

这两个是相同的......将相同的值分配给不同的变量。

因为,否则条件

if (DBErr.Contains(MachineErrSplit[i]))

if (!DBErr.Contains(MachineErrSplit[i]))
于 2013-02-25T08:49:05.827 回答