Chapter Four - Exception Handling
Chapter Four - Exception Handling
EXCEPTION HANDLING
2
Cont’d…
3
Cont’d…
7
C# - Exception Handling
8
Cont’d…
9
Cont’d…
try {
result = num1 / num2;
} catch (DivideByZeroException e) {
15
Cont’d…
• Some of the predefined exception classes derived from the
Sytem.SystemException class …
System.DivideByZeroException: Handles errors generated from
dividing a dividend with zero.
System.InvalidCastException: Handles errors generated during
typecasting.
System.OutOfMemoryException: Handles errors generated from
insufficient free memory.
System.StackOverflowException: Handles errors generated from
stack overflow.
16
Cont’d…
}
}
20
Creating User-Defined Exceptions