有没有其他方法可以优化下面的代码?我觉得下面的代码对于它所执行的操作来说是巨大的。针对相同条件的多个值
if ((currentElement == null ||
(firstGridRow["Low"].ToString() == string.Empty ||
firstGridRow["High"].ToString() == string.Empty ||
firstGridRow["Mean"].ToString() == string.Empty ||
firstGridRow["StdDev"].ToString() == string.Empty)))
{
continue;
}
if (newRow.Length != 0)
{
AddColorList(currentElement, opid, currentLow, "Low", newRow, listCollectionLow);
AddColorList(currentElement, opid, currentHigh, "High", newRow, listCollectionHigh);
AddColorList(currentElement, opid, currentMean, "Mean", newRow, listCollectionMean);
AddColorList(currentElement, opid, currentStdDev, "StdDev", newRow, listCollectionStdDev);
}
你应该问这对http://codereview.stackexchange.com/! –
什么是firstGridRow?以及循环如何看起来像? –
为什么在每个循环迭代中检查'firstGridRow [“Low”]和其他列,即使它始终是同一行? –