Solved

Get confuse with Try..Catch..Finally block

Posted on 2004-10-18
2
198 Views
Last Modified: 2010-04-24

Hi experts, I have an question about Exception Handling please help.

I know that we use Try structure in vb.net to catch any error.
Try
....
...
Catch e as excetion
...
...
Finally
...
...

The question is that: The Finally block will always execute, right? but when I use try in try (nested try) only the last finally block will execute. So how can I make rest of finally block execute all?

Thank you.
0
Comment
Question by:veayou
[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 10

Accepted Solution

by:
123654789987 earned 300 total points
ID: 12336877
This is a tested solution try this

nested try/finally statement

    static void Main()
        while (true)
            try
                try
                    Console.WriteLine("Before break");
                    break;
                end try
                finally
                    Console.WriteLine("Innermost finally block");
                end finally
          end try
            finally
                Console.WriteLine("Outermost finally block");
           end finally
       
        Console.WriteLine("After break");
   

Output is as follows

    Before break
    Innermost finally block
    Outermost finally block
    After break
0
 
LVL 7

Assisted Solution

by:J_Mak
J_Mak earned 200 total points
ID: 12337303
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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