C# Exception Handling - c# - c# tutorial - c# net

What is Exception handling in C# ?

  • Exception Handling in C# is a process to handle runtime errors.
  • We perform exception handling so that normal flow of the application can be maintained even after runtime errors.
  • In C#, exception is an event or object which is thrown at runtime.
  • All exceptions the derived from System.Exception class. It is a runtime error which can be handled.
  • If we don't handle the exception, it prints exception message and terminates the program.
 Exception Handling

Exception Handling


  • It maintains the normal flow of the application. In such case, rest of the code is executed event after exception.

C# Exception Classes

  • All the exception classes in C# are derived from System.Exception class. Let's see the list of C# common exception classes.
Exception Description
System.DivideByZeroException handles the error generated by dividing a number with zero.
System.NullReferenceException handles the error generated by referencing the null object.
System.InvalidCastException handles the error generated by invalid typecasting.
System.IO.IOException handles the Input Output errors.
System.FieldAccessException handles the error generated by invalid private or protected field access.
Related Tags: kurs c# , c# programmieren , tutorial c# visual studio , learn programming with c# , c# kurs online , the best way to learn c# , c# tutorial for complete beginners from scratch , tuto c# , manual c#

C# Exception Handling Keywords

  • In C#, we use 4 keywords to perform exception handling:
    • try
    • catch
    • finally, and
    • throw
 Try Catch Exception

Try Catch Exception

Related Searches to C# Exception Handling

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.