Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Correct Code Execution Path

Posted on 2011-09-27
1
Medium Priority
?
195 Views
Last Modified: 2012-05-12
I am curious that if you have a function that uses a using keyword, should the return element come the end using or does it not matter

ie this is what I have

    Using log As New EventLog(EVENTLOGNAME)

                Dim errors(log.Entries.Count - 1) As structLoggedError

                For Each entry In log.Entries
                    Using reader As New StringReader(entry.Message)
                        errors(i) = CType(serializer.Deserialize(reader), structLoggedError)
                        i += 1
                    End Using
                Next

                Return errors <<<<<<<<<<<

            End Using
0
Comment
Question by:rocky050371
1 Comment
 
LVL 10

Accepted Solution

by:
eguilherme earned 2000 total points
ID: 36709100
it doesnt matter, you can place the return statement inside the using clause, it will dispose the used object as it should

http://msdn.microsoft.com/en-us/library/htd05whh.aspx
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question