Compiler Error CS0160

A previous catch clause already catches all exceptions of this or of a super type ('type')

A series of catch statements needs to be in decreasing order of derivation. For example, the most derived objects must appear first.

For more information, see Exceptions and Exception Handling.

The following sample generates CS0160:

// CS0160.cs  
public class MyClass2 : System.Exception {}  
public class MyClass  
{  
   public static void Main()  
   {  
      try {}  
  
      catch(System.Exception) {}   // Second-most derived; should be second catch  
      catch(MyClass2) {}   // CS0160  Most derived; should be first catch  
   }  
}