.

C Sharp Exception Handling Assignment Help

EXCEPTION HANDLING

  • Its a run time error which falls at some stage in the implementation of a program.
  • For example divide by zero raises an exception
  • Exceptions transfers control from one part of a program to another part of a program.
  • This mechanism has four keywords associated to it .They are try, catch, finally, and throw.
  • try block has exception raising doubtful statements
  • In this block exception is activated .It can have one or more catch blocks.
  • throw keyword throws an exception
  • catch block catches an exception
  • more than one statement can be used for a single try statement
  • finally block finally executed irrespective of an exception is thrown or not thrown.

C Sharp Exception Handling Assignment Help By Online Tutoring and Guided Sessions from assignmenthippo.com


Syntax

try
{
// doubtful statements
} catch ( Exceptionname excp1 )
{
// statements
} catch ( Exceptionname excp2 )
{
// statements
} catch ( Exceptionname excpn )
{
// statements
} finally {
// statements always executed
}

Exception Classes in C#

  • Exception
  • ApplicationException
  • SystemException
  • IO.IOException
  • IndexOutOfRangeException
  • ArrayTypeMismatchException
  • NullReferenceException
  • DivideByZeroException
  • InvalidCastException
  • OutOfMemoryException
  • System.StackOverflowException

Example

exception handling image 1
.