Exception Filters in C# 6.0

This feature helps to filter the exception messages by providing conditional statements which returns true or false at catch block.

Suppose, if you want to log the exception in catch block only if inner exception is not null. In that scenario, you can write the code like the below.

 So, In the catch block if condition returns true then it enters into the catch block and it would log and throws the exception.
  1. try  
  2. {  
  3.    //Some Exception Throws  
  4. }  
  5. catch(Exception ex) if(ex.InnerException != null)  
  6. {  
  7.    //Log the Exception and throw  
  8.    throw;  
  9. }  
  10. finally  
  11. {