Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get confuse with Try..Catch..Finally block

Posted on 2004-10-18
2
Medium Priority
?
201 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

Technology Partners: 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 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