30.8.08

Exceptions In C#.NET

In C# Exception / Error can be classified into
  • compile-time errors
  • runtime errors

Compile-time errors are errors that can be found during compilation process of source code. Most of them are syntax errors. Runtime errors happen when program is running. It is very difficult to find and debug the run-time errors. These errors also called exceptions.Exception generates an exception call at runtime. Exceptions in C# can be called using two methods:

  • Using the throw operator. It call the manage code anyway and process an exception.
  • If using the operators goes awry, it can generate an exception.

All Exception are inherited from base class named System.Exception.These class process many kind of exception:

  • out of memory exception,
  • stack overflow exception,
  • null reference exception,
  • index out of range exception,
  • invalid cast exception,
  • arithmetic exception etc.

No comments: