title: Casting between classes that share the same interface
body: <p>I have two interfaces <strong>IHeaderRow</strong>, and <strong>IDetailRow</strong></p>
  
  <p>I then have an object that implements both <strong>RawRow:IHeaderRow, IDetailRow</strong></p>
  
  <p>I then need to cast it to <strong>HeaderRow</strong> which implements <strong>IHeaderRow</strong>.</p>
  
  <p>But when I try, it ends up being null or giving an exception.</p>
  
  <p>I can cast <strong>ObjectRawRow</strong> to either interface <strong>IHeaderRow</strong>, or <strong>IDetailRow</strong></p>
  
  <pre><code>var ObjectIHeaderRow = ObjectRawRow as IHeaderRow;
  var ObjectIDetailRow = ObjectRawRow as IDetailRow;
  </code></pre>
  
  <p>But I can not cast <strong>ObjectRawRow</strong> to <strong>HeaderRow</strong> , or <strong>ObjectIHeaderRow</strong> to <strong>HeaderRow</strong>.</p>
  
  <p>It throws the error <em>Cannot convert source type 'IA' to target type 'A'</em></p>
  
  <p>I need to cast it into the actual class <strong>HeaderRow</strong>.</p>
  
  <p>Thoughts?</p>
  
  <p>EDIT:</p>
  
  <p>Even though setting up an explicit cast took care of the issue I thought I'd provide an answer to the people wondering, WHY I was doing what I was.</p>
  
  <p>In short, I'm sequentially processing a file.  Line by line.  I read the row into RawRow, and until I look at a few values, I don't actually know what type of row it is going to be.  I then wanted to cast it to the proper type.</p>