• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/8

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

8 Cards in this Set

  • Front
  • Back

Name two subclasses of arithmetic exception

OverflowException


DivideByZeroException

What are two common properties for all exceptions?

Message: gets a message that briefly describes the exception




StackTrace: gets a string that lists the methods that were called before the exception occurred

Common method for all exceptions

GetType()




Gets the type of the current exception

Display a dialog that shows the type of the exception in the title bar and then in the middle displays a brief description and the call stack

try{...}

catch(Exception ex)


{


MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Exception: " + ex.GetType.ToString());


}

Show syntax for try-catch-finally that catches multiple exceptions

try{...}


catch(ArithmeticException ex){...}


catch(DivideByZeroException ex){...}


catch(Exception ex){...}


finally{//do a thing}

syntax for throwing a new exception

throw new ExceptionClass([message]);




//the message is assigned to the Message property

syntax for throwing an existing exception

throw exceptionName;




try{...}


catch(FormatException ex)


{


//do stuff


throw ex


}

When should you throw an exception?

-When a method encounters a situation where it cannot complete its task


-When you want to generate an exception to test an exception handler


-When you want to catch the exception, perform some processing, and then throw the exception again