private static void buildMergeDownstreamUpStream(IFeatureSet newshed, int IDFieldNum, int LinksFieldNum, int DSFieldNum, int USFieldNum1, int USFieldNum2) { for (int i = 0; i <= newshed.NumRows() - 1; i++) { string currDSField = newshed.get_CellValue(DSFieldNum, i).ToString(); if (currDSField != "-1") { for (int j = 0; j <= newshed.NumRows() - 1; j++) { string links = newshed.get_CellValue(LinksFieldNum, j).ToString(); string[] split = links.Split(','); for (int k = 0; k <= split.Length - 1; k++) { if (split[k].Trim() == currDSField) { newshed.EditCellValue(DSFieldNum, i, newshed.get_CellValue(IDFieldNum, j)); string upstream1 = newshed.get_CellValue(USFieldNum1, j).ToString(); if (upstream1 == "-1") { newshed.EditCellValue(USFieldNum1, j, newshed.get_CellValue(IDFieldNum, i)); } else { newshed.EditCellValue(USFieldNum2, j, newshed.get_CellValue(IDFieldNum, i)); } break; } } } } } }