Skip to main content

Posts

Showing posts from March, 2020

Exceptions and Exception handling in C# Explained

Exceptions and Exception handling in C# The C# language's exception handling features help you deal with any unexpected or exceptional situations that occur when a program is running. Exception handling uses the  try ,  catch , and  finally  keywords to try actions that may not succeed, to handle failures when you decide that it is reasonable to do so, and to clean up resources afterward. Exceptions can be generated by the common language runtime (CLR), by the .NET Framework or any third-party libraries, or by application code. Exceptions are created by using the  throw  keyword. In many cases, an exception may be thrown not by a method that your code has called directly, but by another method further down in the call stack. When this happens, the CLR will unwind the stack, looking for a method with a  catch  block for the specific exception type, and it will execute the first such  catch  block that is found. If it finds no approp...