if statement - Two ifs and one else in C#. What happens? -


for example:

if(cond1) if(cond2) docond2(); else docond3(); 

will else statement considered else of first if or second if? why? (is there explanation syntactic point of view?) answer same in other c-based programming languages such c , java?

note: not homework. can test it, , use curly brackets if don't default behaviour, i'm curious reason.

edit guys, apparently there serious mistake in original example. please check again. know, it's embarrassing. sorry.

as per msdn

in nested if statements, else clause belongs last if not have corresponding else.

also c , c++, conditions can evaluated result of 0 false , other number true. in c#, condition must evaluate boolean value true/false

edit per edit nested if, inner 1 evaluated when true , still else inner if


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -