I was just curious. I have just written my first major code in C#, using try-catch-finally. I was wondering if there existed such a method to handle errors if there was additionally stuff to be processed after inside the finally block. Thanks.
Asked
Active
Viewed 140 times
0
-
What stuff to be processed? You have code that's in the try block. Unless it throws, it will be executed, and then the code in the finally block will be executed, and then the control flow goes to whatever is after the try-catch-finally construct. Where would the additional stuff live? – David Thornley May 05 '11 at 20:46
-
Can you reword the question, it's not 100% clear as to what your asking. – RubbleFord May 05 '11 at 20:46
-
"after inside the finally block" doesn't help. If you want code to execute after the finally block, put it there. If you want something else, you'll have to be more specific. Try editing to include a sample control structure showing where the additional code goes. – David Thornley May 05 '11 at 20:52
-
I hope that this helps it to make sense. I have a code the inserts data into Oracle table from MS Access while inside a try block, but because I need the most recent data that from the MS Access table. I add to the finally block a few lines that deletes all but the most data. The additional deletion portion is done because this Oracle table is populated often by a windows service. – LaDante Riley May 05 '11 at 20:55
-
I still don't get it. You say you want to do something in the finally block; why not just put the code there? What are you doing that you can't just put code in the try block, or the finally block, or after the finally block? – David Thornley May 05 '11 at 21:02
2 Answers
0
i know nothing about c but logic tell me if your are outside the try-catch-finally you are out of the scope of that conditional statement and therefore need a new try-catch-finally or something similar

mcgrailm
- 17,469
- 22
- 83
- 129
0
You could nest another try-catch block in your finally clause (if I understand your question correctly):
try
{
...
}
catch
{
...
}
finally
{
try
{
...
}
catch
{
...
}
}

ChristopheD
- 112,638
- 29
- 165
- 179