I met the following code in C #.
if(condition0) statement0; else if(condition1) statement1; else if(condition2) statement2; else if(condition3) statement3; ... else if(conditionN) statementN; else lastStatement;
Some of my colleagues tell me that this is an else if . However, I am convinced that this is actually a multi-level nested if-else . I know that without delimiters {} one statement is allowed in if or else . Therefore, in this case, I think it will be equivalent to the following code.
if(condition0) statement0; else if(condition1) statement1; else if(condition2) statement2; else if(condition3) statement3; else ...
Please note that everything I changed was a space. This indentation works because every else returns to the most recent if when there are no delimiters.
Can someone clarify if the else if format in the first example matches the compiler differently than the nested if-else format in the second example?
Aviv B. Jul 30. '10 at 19:57 2010-07-30 19:57
source share