title: Cast an object into an object from a derived class
body: <p>I have a class <code>Record</code> that works fine:</p>
  
  <pre><code>public class Record 
  {
      protected string table;
      protected string idcolumn;
      public Record(string _table, string _idcol, int _id) 
      {
          table = _table;
          idcolumn = _idcol;
          Id = _id;
      }
  }
  </code></pre>
  
  <p>I also have a class <code>Order</code> that is derived from <code>Record</code>, that implements extra methods, only applicable on a certain type of record:</p>
  
  <pre><code>class Order : Record 
  {
      public void Start() 
      {
      }
  }
  </code></pre>
  
  <p>In my application, I have an object <code>theRecord</code> of type <code>Record</code> that I want to cast to <code>Order</code>, so that I can call the <code>Start</code> method on it. </p>
  
  <p>I tried to cast it: </p>
  
  <pre><code>Order r = (Order)theRecord;
  </code></pre>
  
  <p>but that throws an <code>InvalidCastException</code>.</p>
  
  <p>I am thinking that I could create a new constructor for <code>Order</code> that takes a <code>Record</code>, but I already have the object (which is built by fetching a record from the database).</p>
  
  <p>How could I implement this correctly?</p>