in Personal

.NET Quiz Question #1

What happens when I compile and/or execute the follow code (in VB.NET, but it’s the same for C#):

Private Function DoSomething() As Boolean
Try
Return True
Catch ex As Exception
Finally
MessageBox.Show(“Here I am!”)
End Try
End Function

Here are your three answer choices just to make it easier:

1) The function simply doesn’t compile (if you pick this, then say why it won’t)
2) The function returns the value “true” (if you pick this one, say why does the message box not show)
3) The function shows the message box (if you pick this, then say what is the value returned from the function)

Quite interesting isn’t it? 🙂 (BTW, I took this from Glen Gordon’s blog…BUT don’t read the answer or try it until you’ve guessed.)