I have a for loop that I want to write without curly braces (perfectionism and laziness). Will this chain of conditions work in a loop or not?
for(int i = 0; i < mass.count; i++) if(a < b) { } else if (a > b) { } else { } Yes, counts as one sentence.
You can submit the original if
if(a < b) { } else if (a > b) { } else { } as
if(a < b) вложенный-оператор else вложенный-оператор where the first nested-operator is the empty block operator {} (empty block), and the second nested operator is, in turn, the if statement if (a > b) { } else { }
As written in the C # Programming Language book with the participation of Anders Hejlsberg as author (Chapter 8. Operators)
"The nested operator can be used inside other operators, and the nesting level is not limited."
Perhaps there are some restrictions on nesting in the language specification, however, they are not significant for real programs.
Source: https://ru.stackoverflow.com/questions/577620/
All Articles
ifevery iteration of the loop is checked, andelseonly after it? - VladD