C# Exception Handling

HTML
CSS
C#
SQL

Exception Handling

An exception is an issue that occurs during the execution of a program.
C# exception handling handle any unexpected or exceptional situations that occur when a program is getting executed.
C# exception handling consists of 4 keywords : try, catch, throw, finally.
Try : It contains the code which might get an exception
Catch: This block is used to handle any resulting exceptions
Finally: This block contains code that is run whether or not an exception is thrown in the try block
Throw: This statement is used to throw an exception when any problem occurs in the program.

C# Exceptions
When executing C# code, different errors can occur: coding errors made by the programmer, errors due to wrong input, or other unforeseeable things.
When an error occurs, C# will normally stop and generate an error message. The technical term for this is: C# will throw an exception (throw an error).
C# try and catch
The try statement allows you to define a block of code to be tested for errors while it is being executed.
The catch statement allows you to define a block of code to be executed, if an error occurs in the try block.