Solved

Correct Code Execution Path

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now