SlideShare a Scribd company logo
1 of 16
Exception Handling in C#
Prepared by:
Ezzat Harki
Copyright © 2013 Ezzat Harki
What Aim in This presentation
 Introduction to exception
 Advantage for pupil
 Mark for myself
Copyright © 2013 Ezzat Harki
What is Exception
 An exception is a problem that arises during the execution of a program. A C#
exception is a response to an exceptional circumstance that arises while a
program is running, such as an attempt to divide by zero.
Copyright © 2013 Ezzat Harki
This mechanism consist of
 Find the problem
 Inform that an error has occurred
 Receive the error information
 Take corrective action
Copyright © 2013 Ezzat Harki
Type of all Exception Class in C# library
Name
Access Violation Exception
AggregateException
AppDomainUnloadedException
ApplicationException
ArgumentException
ArgumentNullException
ArgumentOutOfRangeException
ArithmeticException
ArrayTypeMismatchException
BadImageFormatException
CannotUnloadAppDomainException
Copyright © 2013 Ezzat Harki
Cont.Type of all Exception Class in C# library
Name
ContextMarshalException
DataMisalignedException
DecoderFallbackException
DirectoryNotFoundException
DivideByZeroException
DllNotFoundException
DriveNotFoundException
DuplicateWaitObjectException
EncoderFallbackException
EndOfStreamException
EntryPointNotFoundException
ExecutionEngineException
Copyright © 2013 Ezzat Harki
Cont.Type of all Exception Class in C# library
Name
FieldAccessException
FileLoadException
FileNotFoundException
FormatException
IndexOutOfRangeException
InsufficientExecutionStackException
InsufficientMemoryException
InternalBufferOverflowException
InvalidCastException
InvalidDataException
InvalidOperationException
InvalidProgramException
InvalidTimeZoneException
IOException
Copyright © 2013 Ezzat Harki
Cont.Type of all Exception Class in C# library
Name
KeyNotFoundException
MemberAccessException
MethodAccessException
MissingFieldException
MissingMemberException
MissingMethodException
MulticastNotSupportedException
NotFiniteNumberException
NotImplementedException
NotSupportedException
NullReferenceException
ObjectDisposedException
OperationCanceledException
OutOfMemoryException
Copyright © 2013 Ezzat Harki
Cont.Type of all Exception Class in C# library
Name
OverflowException
PathTooLongException
PlatformNotSupportedException
RankException
StackOverflowException
SystemException
TaskCanceledException
TaskSchedulerException
TimeoutException
TimeZoneNotFoundException
TypeAccessException
TypeInitializationException
TypeLoadException
TypeUnloadedException
Copyright © 2013 Ezzat Harki
Cont.Type of all Exception Class in C# library
Name
UnauthorizedAccessException
UriFormatException
Copyright © 2013 Ezzat Harki
In C# Exception Handling is Managed by
that Keyword
 Try
 Catch
 Finally
 Throw
 checked
 Unchecked
Copyright © 2013 Ezzat Harki
Diagram working try & catch
Try block
Copyright © 2013 Ezzat Harki
Catch block
Statement that
Cause Exception
Statement that
Cause Exception
Diagram working try & catch wit Finally
Try block
Copyright © 2013 Ezzat Harki
finally
Catch blockfinally
Coding How to work try & catch with
finallyTry
{
statement;
//statement causing exception
}
Catch(exception type varable)
{
statement;
//error handling code
}
finally
{
//statement to be executed
statement;
}
Copyright © 2013 Ezzat Harki
It is Coding Example of Exception
 byte x = 129, y = 129, result;
 try
 {
 result =unchecked ((byte)(x + y));
 Console.WriteLine("The Result is Unchecked ", result);
 //at The Top Line Result is Unchecked But Get Wrong Result Becouse byte always can 256 count
 result =checked((byte)(x + y));
 Console.WriteLine("The Result is Checked ", result);
 //But in This Line Checked Result if Get Overflow Tell you
 }
 catch (OverflowException ovex)
 {
 Console.WriteLine(ovex.Message);
 }
Copyright © 2013 Ezzat Harki
Copyright © 2013 Ezzat Harki
If this presentation helped you please visit our page in facebook
and like it thanks for hearing
facebook.com/c.s.soran.university
NoteYou Can Download and Useful This Presentation
But Please Do Not Erase The Owner Name Ezzat Harki
If You Need Help Please Ask me at Facebook.com/Ezzat.Harky

More Related Content

What's hot

Exception Handling
Exception HandlingException Handling
Exception Handlingbackdoor
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javaPratik Soares
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Javaparag
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVASURIT DATTA
 
Exception Handling
Exception HandlingException Handling
Exception HandlingReddhi Basu
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handlingNahian Ahmed
 
Exception handling in asp.net
Exception handling in asp.netException handling in asp.net
Exception handling in asp.netNeelesh Shukla
 
14 exception handling
14 exception handling14 exception handling
14 exception handlingjigeno
 
Exceptionhandling
ExceptionhandlingExceptionhandling
ExceptionhandlingNuha Noor
 
Exception handling
Exception handlingException handling
Exception handlingpooja kumari
 
Exception Handling Java
Exception Handling JavaException Handling Java
Exception Handling Javaankitgarg_er
 
130410107010 exception handling
130410107010 exception handling130410107010 exception handling
130410107010 exception handlingHemant Chetwani
 
Exceptions overview
Exceptions overviewExceptions overview
Exceptions overviewBharath K
 

What's hot (20)

Exception Handling
Exception HandlingException Handling
Exception Handling
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Exception handling in python
Exception handling in pythonException handling in python
Exception handling in python
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
What is Exception Handling?
What is Exception Handling?What is Exception Handling?
What is Exception Handling?
 
Exception handling in asp.net
Exception handling in asp.netException handling in asp.net
Exception handling in asp.net
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Exception handling
Exception handlingException handling
Exception handling
 
14 exception handling
14 exception handling14 exception handling
14 exception handling
 
Exceptionhandling
ExceptionhandlingExceptionhandling
Exceptionhandling
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception Handling Java
Exception Handling JavaException Handling Java
Exception Handling Java
 
130410107010 exception handling
130410107010 exception handling130410107010 exception handling
130410107010 exception handling
 
Exceptions overview
Exceptions overviewExceptions overview
Exceptions overview
 

Similar to Exception handling in c

Java coding pitfalls
Java coding pitfallsJava coding pitfalls
Java coding pitfallstomi vanek
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationJames Hamilton
 
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Andrzej Jóźwiak
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsRandy Connolly
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingChaAstillas
 
exceptions in java
exceptions in javaexceptions in java
exceptions in javajaveed_mhd
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javapriyankazope
 
exception handling.pptx
exception handling.pptxexception handling.pptx
exception handling.pptxAbinayaC11
 
Best Coding Practices For Android Application Development
Best Coding Practices For Android Application DevelopmentBest Coding Practices For Android Application Development
Best Coding Practices For Android Application DevelopmentKetan Raval
 
Exception handling
Exception handlingException handling
Exception handlingRaja Sekhar
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingKeshav Kumar
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingKeshav Kumar
 
Ch-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for allCh-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for allHayomeTakele
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertionRakesh Madugula
 
Java SE 11 Exception Handling
Java SE 11 Exception HandlingJava SE 11 Exception Handling
Java SE 11 Exception HandlingAshwin Shiv
 
Class notes(week 8) on exception handling
Class notes(week 8) on exception handlingClass notes(week 8) on exception handling
Class notes(week 8) on exception handlingKuntal Bhowmick
 

Similar to Exception handling in c (20)

Java coding pitfalls
Java coding pitfallsJava coding pitfalls
Java coding pitfalls
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 Presentation
 
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation Controls
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
exceptions in java
exceptions in javaexceptions in java
exceptions in java
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
exception handling.pptx
exception handling.pptxexception handling.pptx
exception handling.pptx
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
 
Best Coding Practices For Android Application Development
Best Coding Practices For Android Application DevelopmentBest Coding Practices For Android Application Development
Best Coding Practices For Android Application Development
 
Exception handling
Exception handlingException handling
Exception handling
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programming
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programming
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
Ch-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for allCh-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for all
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertion
 
Java SE 11 Exception Handling
Java SE 11 Exception HandlingJava SE 11 Exception Handling
Java SE 11 Exception Handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Class notes(week 8) on exception handling
Class notes(week 8) on exception handlingClass notes(week 8) on exception handling
Class notes(week 8) on exception handling
 

Recently uploaded

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

Exception handling in c

  • 1. Exception Handling in C# Prepared by: Ezzat Harki Copyright © 2013 Ezzat Harki
  • 2. What Aim in This presentation  Introduction to exception  Advantage for pupil  Mark for myself Copyright © 2013 Ezzat Harki
  • 3. What is Exception  An exception is a problem that arises during the execution of a program. A C# exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Copyright © 2013 Ezzat Harki
  • 4. This mechanism consist of  Find the problem  Inform that an error has occurred  Receive the error information  Take corrective action Copyright © 2013 Ezzat Harki
  • 5. Type of all Exception Class in C# library Name Access Violation Exception AggregateException AppDomainUnloadedException ApplicationException ArgumentException ArgumentNullException ArgumentOutOfRangeException ArithmeticException ArrayTypeMismatchException BadImageFormatException CannotUnloadAppDomainException Copyright © 2013 Ezzat Harki
  • 6. Cont.Type of all Exception Class in C# library Name ContextMarshalException DataMisalignedException DecoderFallbackException DirectoryNotFoundException DivideByZeroException DllNotFoundException DriveNotFoundException DuplicateWaitObjectException EncoderFallbackException EndOfStreamException EntryPointNotFoundException ExecutionEngineException Copyright © 2013 Ezzat Harki
  • 7. Cont.Type of all Exception Class in C# library Name FieldAccessException FileLoadException FileNotFoundException FormatException IndexOutOfRangeException InsufficientExecutionStackException InsufficientMemoryException InternalBufferOverflowException InvalidCastException InvalidDataException InvalidOperationException InvalidProgramException InvalidTimeZoneException IOException Copyright © 2013 Ezzat Harki
  • 8. Cont.Type of all Exception Class in C# library Name KeyNotFoundException MemberAccessException MethodAccessException MissingFieldException MissingMemberException MissingMethodException MulticastNotSupportedException NotFiniteNumberException NotImplementedException NotSupportedException NullReferenceException ObjectDisposedException OperationCanceledException OutOfMemoryException Copyright © 2013 Ezzat Harki
  • 9. Cont.Type of all Exception Class in C# library Name OverflowException PathTooLongException PlatformNotSupportedException RankException StackOverflowException SystemException TaskCanceledException TaskSchedulerException TimeoutException TimeZoneNotFoundException TypeAccessException TypeInitializationException TypeLoadException TypeUnloadedException Copyright © 2013 Ezzat Harki
  • 10. Cont.Type of all Exception Class in C# library Name UnauthorizedAccessException UriFormatException Copyright © 2013 Ezzat Harki
  • 11. In C# Exception Handling is Managed by that Keyword  Try  Catch  Finally  Throw  checked  Unchecked Copyright © 2013 Ezzat Harki
  • 12. Diagram working try & catch Try block Copyright © 2013 Ezzat Harki Catch block Statement that Cause Exception Statement that Cause Exception
  • 13. Diagram working try & catch wit Finally Try block Copyright © 2013 Ezzat Harki finally Catch blockfinally
  • 14. Coding How to work try & catch with finallyTry { statement; //statement causing exception } Catch(exception type varable) { statement; //error handling code } finally { //statement to be executed statement; } Copyright © 2013 Ezzat Harki
  • 15. It is Coding Example of Exception  byte x = 129, y = 129, result;  try  {  result =unchecked ((byte)(x + y));  Console.WriteLine("The Result is Unchecked ", result);  //at The Top Line Result is Unchecked But Get Wrong Result Becouse byte always can 256 count  result =checked((byte)(x + y));  Console.WriteLine("The Result is Checked ", result);  //But in This Line Checked Result if Get Overflow Tell you  }  catch (OverflowException ovex)  {  Console.WriteLine(ovex.Message);  } Copyright © 2013 Ezzat Harki
  • 16. Copyright © 2013 Ezzat Harki If this presentation helped you please visit our page in facebook and like it thanks for hearing facebook.com/c.s.soran.university NoteYou Can Download and Useful This Presentation But Please Do Not Erase The Owner Name Ezzat Harki If You Need Help Please Ask me at Facebook.com/Ezzat.Harky