Abort on exception?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sweetiecakes

    #1

    Abort on exception?

    A simple Google search didn't result anything (although I'm not known
    for my Google usage skills), but how would I stop the operation when an
    exception occurs?

    (For example, how would I prevent "int four = 2 + 2;" from being
    executed in the following example:

    try {
    int division = 100/0;
    int four = 2 + 2;
    }
    catch (DivideByZeroEx ception de) {
    Console.WriteLi ne("you've destroyed the world, way to go");
    } ?)
  • kimiraikkonen

    #2
    Re: Abort on exception?

    On Apr 20, 1:57 pm, sweetiecakes <sweetiespamca. ..@mail.comwrot e:
    A simple Google search didn't result anything (although I'm not known
    for my Google usage skills), but how would I stop the operation when an
    exception occurs?
    >
    (For example, how would I prevent "int four = 2 + 2;" from being
    executed in the following example:
    >
    try {
    int division = 100/0;
    int four = 2 + 2;}
    >
    catch (DivideByZeroEx ception de) {
    Console.WriteLi ne("you've destroyed the world, way to go");
    >
    } ?)
    Using try-catch, when an exception is thrown resulting as in your
    catch block message, operation is stopped in "try" and catch block is
    executed.

    HTH,

    Onur Güzel

    Comment

    • Peter Morris

      #3
      Re: Abort on exception?

      (For example, how would I prevent "int four = 2 + 2;" from being executed
      in the following example:
      It wont be executed. Put a breakline on your code and step through it to
      see what happens.


      Comment

      Working...