I'm assuming you mean VB.Net.
According to the grammar in the VB Language spec, which you can read here:
http://www.microsoft.com/Downloads/thankyou.aspx?familyId=39de1dd0-f775-40bf-a191-09f5a95ef500&displayLang=en
The result should be "6".
This is because the grammar for a "line if statement" is:
If BooleanExpression Then Statements [ Else Statements ] StatementTerminator
and "statements" is defined to be
Statements ::=
[ Statement ] |
Statements : [ Statement ]
Edit:
I would like to note that debugging the code is not "cheating".
I used to work on the VB compiler team at Microsoft.
There were times where the spec was ambiguous, or didn't match what we had actually shipped. In several of those cases the solution (what we did to fix it) was always based on "well... what does the compiler do now".
Sometimes we would change the compiler, sometimes we would change the spec.
However,we would always run the compiler to see what it actually did before we made a decision.
So... debugging the code is a big part of figuring out what it does...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…