is it possible to stop the execution of Finally block?

Posted by Naga116 under C# on 8/17/2011 | Points: 10 | Views : 4162 | Status : [Member] | Replies : 5
is it possible to stop the execution of Finally block?

Nagaraju


Responses

Posted by: Jpchoudhari on: 8/17/2011 [Member] Starter | Points: 25

Up
0
Down
no you can not. but you may write criteria to skip execution inside finally block

Kind Regards,
Jay

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nisar87 on: 8/17/2011 [Member] Starter | Points: 25

Up
0
Down
No, its default behaviour that finally will always run either your code run successfully or not.
but you can stop working code inside finally by declaring bool.
like

finally

{
if(isChecked==true)
{
//execute code
}
else
//do nothing
}


_______________________________________
Nisar Ahmad
http://www.dotnetobject.com/

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 8/17/2011 [Member] Bronze | Points: 25

Up
0
Down

Posted by: Jpchoudhari on: 8/17/2011 [Member] Starter | Points: 25

Up
0
Down
in c# you have to use Environment.Exit(0); but that will end your application... probably you would not want to...

Kind Regards,
Jay

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bashkutty on: 7/19/2016 [Member] Starter | Points: 25

Up
0
Down
Environment.Exit(0);
It will end the program without executing finally

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response