What is an Exception in .NET?

What is an Exception in .NET?

- Exceptions are errors that occur during the runtime of a program.
- The advantage of using exceptions is that the program doesn’t terminate due to the occurrence of the exception.
- Whenever an exception is occurred the .NET runtime throws an object of specified type of Exception.
- The class ‘Exception’ is the base class of all the exceptions.

Here are a few common types of exceptions:

- ArgumentException
- ArgumentNullException
- ArgumentOutOfRangeException
- DuplicateWaitObjectException
- ArithmeticException
- DivideByZeroException
- OverflowException
- NotFiniteNumberException
- ArrayTypeMismatchException
- ExecutionEngineException
- FormatException
- IndexOutOfRangeException
- InvalidCastException
- InvalidOperationException
- ObjectDisposedException
- InvalidProgramException
- IOIOException
- IODirectoryNotFoundException
- IOEndOfStreamException
- IOFileLoadException
- IOFileNotFoundException
- IOPathTooLongException
- NotImplementedException
- NotSupportedException
- NullReferenceException
- OutOfMemoryException
- RankException
- SecuritySecurityException
- SecurityVerificationException
- StackOverflowException
- ThreadingSynchronizationLockException
- ThreadingThreadAbortException
- ThreadingThreadStateException
- TypeInitializationException
- UnauthorizedAccessException

It is a runtime error which occurs because of unexpected and invalid code execution.
.Net had enhanced exception handling features. All exceptions inherit from System.Exception.
What are Custom Exceptions? Why do we need them? - C#.NET
What are Custom Exceptions? Why do we need them? - Custom Exceptions are user defined exceptions...
What are Custom Exceptions? - C#.NET
What are Custom Exceptions? - Custom exception needs to derive from the System.Exception class. You can either derive directly from it or use an intermediate exception like SystemException...
What are delegates and why are they required? - C#.NET
What are delegates and why are they required? - The delegates in .NET are like the pointers to the functions in C/C++...
Post your comment