Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1770
  • Last Modified:

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

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
g_johnson
Asked:
g_johnson
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
Solar_FlareCommented:
Finally will ALWAYS be executed, even returning a function from inside the try..catch will still execute the finally code
0

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now