Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

Exception and Exception Handling

The document discusses exception handling in .NET, noting that exceptions identify problems at runtime and are typically generated by the CLR. It explains different types of exceptions like arithmetic, null reference, and index out of range exceptions. Finally, it outlines the try, catch, and finally blocks used to handle exceptions through structured exception handling in .NET.

Uploaded by

Krishna Soni
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Exception and Exception Handling

The document discusses exception handling in .NET, noting that exceptions identify problems at runtime and are typically generated by the CLR. It explains different types of exceptions like arithmetic, null reference, and index out of range exceptions. Finally, it outlines the try, catch, and finally blocks used to handle exceptions through structured exception handling in .NET.

Uploaded by

Krishna Soni
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

Exception

And
Exception Handling
Exception

 Exception are typically regarded


as runtime anomalies.
 Exceptions are often generated by
the CLR That identify the problem at
Hand.
Why Exceptions Occurred ????
Reasons Behind Exceptions.

 Attempting to connect to a database that no


longer exist.
 Caused by math errors such as division by
zero.
 Caused by overflowing the bound of an array.
Caused by bogus user I/O.
Type Of Exceptions
System exception

Arithmetic Exception
DividedByZeroException
OverFlowException
NullRefereceException
IndexOutOfRengeException
InvalidCastException

ApplicationException
UserDefineException
……………..
IOException
FileNotFoundException
…………..
WebException
Exception Handling
• .NET structured exception handling is a
technique well suited to deal with runtime
exceptions.
• Exception handling is a concept which help we
can handle undefined situation .
How Exception Handling??

• Exception handling by the Blocks.


• .Net FrameWork provides few blocks to handle
the Exceptions.
First one is try block.
Second one is catch block.
Third one is finally block.
The basic concept of exception handling are trrowing an exception
and catching it.this is illustrated in Fig.
Try block
Throw exception
Exception object
object
Statement that causes an exception creator

catch block
Exception handler
Statement that handles the exception

Finally block

Statement that always execute


Examples of Blocks
Try
{
int a=10,int b=0;
int c=a/b;
}
Catch(DevideByzeroException ex)
{
Response.Write(ex.ToString);
}
Finally
{
con.Close();
cmd.Distroy();
}
Throw our own Exception
• There may be times when we would like to throw our own exception .we
can do this by using the keyword throw as follow.ex:-

Class Myexception:ApplicationException Void check_age()


{ {
Myexception ex=new myexception(); If(cint(Textbox2.Text<18))
:Base(“your age must be greater then 18”); Throw ex;
} }
Try
{
Check_age();
}
Catch(Myexception ex)
{
Response.Write(“userdefine exception is :”+ex.ToString);
}
Thanks

It’s All About Our Presentation.

Have you Any Queries????

You might also like