Solved

Correct Code Execution Path

Posted on 2011-09-27
1
189 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 500 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

820 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