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

LVL 4
g_johnsonAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor 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_FlareConnect With a Mentor Commented:
Finally will ALWAYS be executed, even returning a function from inside the try..catch will still execute the finally code
0
All Courses

From novice to tech pro — start learning today.