title: c# return upcasted instance as it;s original type
body: <p>I'm trying to return upcasted instance as original type of the one.</p>
  <pre><code>public class Card : MonoBehaviour
  {
      [SerializeField]
      private CardInfo cardInfo;
      public CardInfo Info { get =&gt; cardInfo; }
  }
  
  public abstract class CardConsumable : Card
  {
  }
      
  
  public class CardDataBase : MonoSingleon&lt;CardDataBase&gt;
  {
      //list will contain derived class of cards as element
      private List&lt;Card&gt; allCards = new List&lt;Card&gt;(100);
   
      public dynamic GetCard(int id)
      {
          int count = allCards.Count;
          for (int i = 0; i &lt; count;i++)
              if(allCards[i].Info.Id == id)
              {
                  var card = allCards[i];
                  //tried this but got error
                  //var cardType = card.GetType();
                  //card = card as cardType;
              }
          return null;          
      }
  }
  
  </code></pre>
  <p>for example, in <strong>GetCard()</strong>, if element whose id is same as argument and it's original type is <strong>CardConsumable</strong> then i want to return it as <strong>CardConsumable</strong> not <strong>Card</strong>. in short, i want to return instance as it's original type not upcasted type</p>