如何构建完美的条件
本文关键字:完美 条件 构建 何构建 | 更新日期: 2023-09-27 18:01:01
这是我的问题:我想创建一个程序来检查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
}
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]))