Build 1180: Move declaration closer to usage

Hi,

Another erronous error:

var colNr = 1;
foreach(var cell in row.Split('|')) {
if(cell == "\u2264" + "5") {
excel.SetCellValue(rowNr, colNr++, "");
} else {
excel.SetCellValue(rowNr, colNr++, cell);
}
}

R# suggests to move the declaration of colNr and then to remove the
initializer:

foreach(var cell in row.Split('|')) {
int colNr;
if(cell == "\u2264" + "5") {
excel.SetCellValue(rowNr, colNr++, "");
} else {
excel.SetCellValue(rowNr, colNr++, cell);
}
}

I tend not to follow the suggestion ;)

Thanks,
Alexander

Please sign in to leave a comment.