Solved

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

Posted on 2007-11-19
2
1,764 Views
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)
						{
							try
							{
								c.Open();
								//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);
								break;
							}
							finally
							{
								if (c.State != ConnectionState.Closed)
								{
									c.Close();
								}
							}
						}
					}
				}
			}

Open in new window

0
Comment
Question by:g_johnson
[X]
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
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 350 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.
0
 
LVL 15

Assisted Solution

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

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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