Link to home
Start Free TrialLog in
Avatar of mcainc
mcainc

asked on

VB.NET can you execute code AFTER Return in a function?

I have a function that creates an arraylist & returns it... however after it is returned I want to make the arraylist variable = nothing

I get a warning with that a value isn't returned on all code paths

Dim aList as New ArrayList
Try
    ...
    Return aList
Finalize
    aList = nothing
End Try

is there a better way to do this?
ASKER CERTIFIED SOLUTION
Avatar of Gyanendra Singh
Gyanendra Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
not Finalize use Finally
        Dim aList As New ArrayList
        Try
            Return aList
        Catch ex As Exception
 
        Finally
            aList = Nothing
        End Try

Open in new window