有沒有其他方法可以優化下面的代碼?我覺得下面的代碼對於它所執行的操作來說是巨大的。針對相同條件的多個值
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」]和其他列,即使它始終是同一行? –