المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Go to finally in try block



C# Programming
01-31-2013, 02:30 AM
Hi,

I have two try blocks, two catches and one finally block.

I have logic written in the first try block. But if one of the conditions is hit, I want the program to go to finally block directly, since I am closing all connections here, and then exit program.

If I use Environment.Exit(); then it will end the program, and I would not have closed the connection to database that is open.

How can I force program to go to finally block wit hexecuting the remaining code?