mercredi 29 janvier 2020

Inline if statement inside foreach loop

Is there any way you can do something like this without using the usual If syntax?

foreach (var cell in ws.Cells[header_row, 1, header_row, ws.Dimension.End.Column])
{
    cell.Address == "SomeValue" ? break : continue;
}

Visual Studio doesn't seem to allow an inline If statement with this kind of results.

What am I doing wrong? Or is it actually not possible?

Thanks.

Aucun commentaire:

Enregistrer un commentaire