title: c# - Cast with GetType() and reflection
body: <p>So after implemented <code>Page Object Pattern</code> using <a href="https://www.pluralsight.com/guides/software-engineering-best-practices/getting-started-with-page-object-pattern-for-your-selenium-tests" rel="nofollow noreferrer">this</a> tutorial i have several 
  Pages that derived from <code>BasePageElementMap</code>.</p>
  
  <p>And i want to handle some operation so i have this class:</p>
  
  <pre><code>public class DownloadAttachmentsHandler
      {
          public DownloadAttachmentsHandler(BasePageElementMap basePageElementMap)
          {
              Type type = basePageElementMap.GetType();            
          }
      }
  </code></pre>
  
  <p>Every <code>Pages</code> that derived from <code>BasePageElementMap</code> have this <code>html</code> elements that locate inside its class that derived from <code>BasePageElementMap</code> and from this <code>Page</code> i have this <code>Map</code> object that contains all my <code>HTML</code> elements that i am using.</p>
  
  <pre><code>public class YahooEmailPage: BasePage&lt;YahooEmailPageElementMap, YahooEmailPageValidator&gt;...
  </code></pre>
  
  <p>so in case i am call this function like this:</p>
  
  <pre><code>UploadAttachmentsHandler att = new UploadAttachmentsHandler(new YahooEmailPage().Map);
  </code></pre>
  
  <p>I want to cast this into <code>YahooEmailPage</code> from my <code>DownloadAttachmentsHandler</code> method.</p>
  
  <p>So currently i have this <code>type</code> object, how can i case it into <code>YahooEmailPage</code> ?</p>