0% found this document useful (0 votes)
33 views8 pages

Exception Handling

.NET uses structured exception handling to handle runtime errors. When an exception is raised, an exception object is thrown to the runtime system containing details about the exception. Exceptions can be handled using try-catch-finally blocks, where the try block contains code that may raise exceptions, the catch block handles any exceptions, and the finally block contains cleanup code that always executes. Common examples of exceptions include arithmetic, overflow, and null reference exceptions.

Uploaded by

atul211988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views8 pages

Exception Handling

.NET uses structured exception handling to handle runtime errors. When an exception is raised, an exception object is thrown to the runtime system containing details about the exception. Exceptions can be handled using try-catch-finally blocks, where the try block contains code that may raise exceptions, the catch block handles any exceptions, and the finally block contains cleanup code that always executes. Common examples of exceptions include arithmetic, overflow, and null reference exceptions.

Uploaded by

atul211988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Exception Handling

28-11-2014
10/29/202 ANKIT VERMA 57
0
Exception Handling

“An exception is error condition or any abnormal


condition or unexpected behavior in program and
disturbs the normal flow of instruction”

.NET uses Structured Exception Handling.

Exception Example:
 Arithmetic Exception
 OverFlow Exception
 NullReference Exception

10/29/202 58
0
Exception Handling Steps

When exception is raised, exception object is thrown


to runtime system.
Object contain
 Cause of exception
 Type of exception
 State of program when exception occurred
Itwill handled by runtime & thus leads to
abrupt termination of program.

10/29/202 59
0
Need Of Exception Handling

Handle Runtime Error like


 Unavailability of data
 Trying to access non-existent data
 Trying to update read-only data
 Conversion between data type might fail

10/29/202
0
Exception Handling Blocks
Try…………….. Catch…………….. Finally
Try
 Try Block contain anticipating code which may raise exception.
 Try keyword tell compiler that we want to handle
area of events.
Catch
 Catch Block is handler to catch the exception.
 Catch block tells application what to do if an error occurs.
Finally
 Finally Block is optional.
 Finally keyword will occur regardless if the Try-Catch worked
successfully or not.
10/29/202
0
Program Syntax

Syntax:
 Try
 <statement>
 Catch Ex as Exception
 <statement>
 End Try

10/29/202
0
Program

Progra Outpu
m t

10/29/202
0
Program

Progra Outpu
m t

10/29/202
0

You might also like