title: Custom exception with properties
body: <p>After some research I found that a custom exception should look like this:</p>
  
  <pre><code>using System;
  using System.Runtime.Serialization;
  
  namespace YourNamespaceHere
  {
      [Serializable()]
      public class YourCustomException : Exception, ISerializable
      {
          public YourCustomException() : base() { }
          public YourCustomException(string message) : base(message) { }
          public YourCustomException(string message, System.Exception inner) : base(message, inner) { }
          public YourCustomException(SerializationInfo info, StreamingContext context) : base(info, context) { }
      }
  }
  </code></pre>
  
  <p>But I have small problem. </p>
  
  <p>I want above exception to have two additional fields, say <code>int ID</code> and <code>int ErrorCode</code>. How do I add these two fields and initialize them - shall I add a <em>new</em> constructor, with these two parameters and the message parameter?</p>
  
  <p>Also can you help me and show how to write the serialization methods for this new class which will have the two new properties?</p>
  
  <p>Thank you.</p>