Why does my downcast fail in c#?
<p>I have three types:</p>

<ol>
<li><code>Patient</code> </li>
<li><code>Inpatient : Patient</code> </li>
<li><code>Outpatient : Patient</code></li>
</ol>

<p>I have a method that fills the base patient and all it's properties: <code>PatientRepository.FillPatient()</code> and returns a <code>Patient</code> object.</p>

<p>I then need to check and see what the <code>Patient</code> type is and downcast to either an <code>Outpatient</code> or <code>Inpatient</code>.</p>

<p>When I try to downcast, it is throwing <code>Unable to cast object of type 'Patient' to type 'Inpatient'.</code> This is a run-time error.</p>

<pre><code>if (patient.Type == PatientType.Inpatient)
{
    var inpatient = (Inpatient)patient;             
    return inpatient;
}

public enum PatientType
{
    Inpatient, Outpatient
}
</code></pre>

<p>I have no idea why. Am I fundamentally doing something wrong here?</p>
