An exception is an unexpected event, which occurs during the execution of a program at runtime, which disrupts the normal flow of the program’s instructions. Sometimes during the execution of the program, the user may face the possibility that the program also crashes and show an unexpected event during its runtime execution. This unwanted event is known as Exception and is generally gives the indication that there is something wrong within the code. All exceptions inherited from “SystemException” class which is the main parent class of all exceptions. In general Exceptions are of two types

  • System Level Exception
  • Application Level Exception

System Level Exception and Application Level Exception

System Level Exception:

  • A System Exception occurs when a fatal error is encountered, generally fatal error cannot be recovered because the operating system has encountered a condition which it cannot resolve.
  • System exceptions are generated from the base class System.SystemException. All Exceptions are derived from derived base class named as SystemException.
  • System level exceptions occurs when your DB or DB server crashes etc.

Application Level Exception

  • An application level exception occurs when a recoverable error is encountered in your code like object reference or arithmetic error etc.
  • Application level errors are derived from System.ApplicationException and further it is derived from SystemException which is the parent class of all exceptions.
  • Application level exceptions can be generally handled at the code level using try-catch blocks.
  • With in .Net applications we use the global.aspx file to overwrite  application error in its event named Application_Error.

Explore More

Working With File Class In C#

In C#, ‘File’ class provides many static methods for moving, copying, and deleting files. These Static methods involve moving a file and copying and deleting a file also. Let’s check

How to Read a Text File in C#

In C# ‘File’ class provides static methods to read given text file data. The File.ReadAllText() method opens a text file, reads all the text present in the file into a

C# | How to use Interface references

In C#, you’re permitted to make a reference variable of an interface type or in other words, you’re permitted to form an interface reference variable. Such kind of variable can