Jon Box's Weblog

 


.NET Articles by the Atomic group

MSDN RDs









Subscribe to "Jon Box's Weblog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 

 

  Friday, October 24, 2003


Based on the following snippet, answer the following questions:

  • What is the value of returnValue when the last line of Test executes?
  • What value is returned from the Test function?
  • Would the code in the Finally block execute?
  • How many Return statements (or Exit Function or Exit Sub) should a function have?

 

 

Module Module1

 

    Sub Main()

        Dim x As Integer = Test()

    End Sub

 

    Function Test() As Integer

        Dim returnValue As Integer

 

        Try

            returnValue = 1

            Return returnValue

 

        Catch ex As Exception

            returnValue = 2

 

        Finally

            returnValue = 3

 

        End Try

 

        Return returnValue

    End Function

End Module


4:45:07 PM    comment []


Click here to visit the Radio UserLand website. © Copyright 2004 Jon Box.
Last update: 8/31/2004; 11:59:56 PM.

October 2003
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Sep   Nov