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

Posted on 2007-11-19
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
LVL 143

Accepted Solution

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.
LVL 15

Assisted Solution

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
2 questions 10 29
SqlDependency to get update from sql to my c# app 2 65
transaction in, sql server 6 43
C# class library debugging - Breakpoint will not hit. 8 21
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

828 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