Exception handling helps developers structure their programs in a way that helps them handle both expected and unexpected scenarios. Often, application logic may throw some form of unhandled exception, for example, a code block trying to write to a file on a system that ends up with a file with a use exception. Such scenarios can be handled if proper exception handling is in place.
Exception handling uses the try, catch, and finally keywords to allow us to write code that may not succeed and can be handled when required, as well as to help us clean up resources once the try block has been executed. These exceptions can be thrown by CLR, .NET Framework, or by external libraries that are used in your code.