title: Returning a custom exception
body: <p>I am trying to implement my own Exception class in C#. For this purpose I have created a CustomException class derived from Exception.</p>
  
  <pre><code>class CustomException : Exception
  {
      public CustomException()
          : base() { }
  
      public CustomException(string message)
          : base(message) { }
  
      public CustomException(string format, params object[] args)
          : base(string.Format(format, args)) { }
  
      public CustomException(string message, Exception innerException)
          : base(message, innerException) { }
  
      public CustomException(string format, Exception innerException, params object[] args)
          : base(string.Format(format, args), innerException) { }
  }
  </code></pre>
  
  <p>Then I use it</p>
  
  <pre><code>static void Main(string[] args)
  {
      try
      {
          var zero = 0;
          var s = 2 / zero;
      }
      catch (CustomException ex)
      {
          Console.Write("Exception");
          Console.ReadKey();
      }
  }
  </code></pre>
  
  <p>I'm expecting I will get my exception but all I get is a standard DivideByZeroException. How can I catch a divide by zero exception using my CustomException class? Thanks.</p>