try again in C# exception handling

G

Guest

I'm new to C#. Please answer my following questions about c# exception
handling.

What happens and how an exception handled if it occurs in "catch" block
while already processing another exception.

In an exception "catch" block I am showing a dialog box to user with option
of "try again" or "cancel". How can I implement the "try again" option, is
there any way in c# exception handling to run the same exception statement
again.

regards,
Adil
 
K

Kevin Spencer

You can use nested try/catch blocks in your code. If some operation in a
catch block might raise an exception, put it into a try/catch block of its
own.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.
 
G

Guest

Hi Adil,

Stick it in a loop.

Pseudo-code-ish:

done = false;

while !done
{

try
{
codeThatMightFail

done = true;
}

catch
{
if( !( DialogBox = TryAgain )) done = true;
}

}


Nothing additionally C# specific here.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top