Solved

Get confuse with Try..Catch..Finally block

Posted on 2004-10-18
2
194 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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