Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


how does break affect try .. catch... finally in C# 2003

Posted on 2007-11-19
Medium Priority
Last Modified: 2008-02-01
In this scenario, will the break cause the finally to be skipped?

foreach (Xceed.Grid.DataRow dr in this.gcResults.DataRows)
				foreach (Xceed.Grid.DetailGrid dGrid in dr.DetailGrids)
					foreach (Xceed.Grid.DataRow drSub in dGrid.DataRows)
						if (Convert.ToBoolean(drSub.Cells[6].Value) == true)
								//expire the old record
								//insert the new record
							catch (Exception ex)
								MessageBox.Show (this,"Failure To Write Record | " + ex.Message,"Commercial Bag PA Bulk Update",MessageBoxButtons.OK,MessageBoxIcon.Warning);
								if (c.State != ConnectionState.Closed)

Open in new window

Question by:g_johnson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 1400 total points
ID: 20315491
break where?

anyhow, break will only terminate the closest loop or switch, so it will only terminate that. it will NOT skip the finally.
LVL 15

Assisted Solution

Solar_Flare earned 600 total points
ID: 20315524
Finally will ALWAYS be executed, even returning a function from inside the try..catch will still execute the finally code

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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