?
Solved

Get confuse with Try..Catch..Finally block

Posted on 2004-10-18
2
Medium Priority
?
199 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 1200 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 800 total points
ID: 12337303
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

777 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