title: Can overloaded methods work with different types without having to cast in c#?
body: <p>I have 3 simple classes for this example:</p>
  
  <pre><code> public class User
  {
      public string FirstName { get; set; }
  }
  
  public class E : User
  {
      public string MiddleInitial { get; set; }
  }
  public class F : User
  {
      public string LastName { get; set; }
  }
  </code></pre>
  
  <p>I have a few simple Print methods that I'm overloading to take a specific type. Don't mind response write, it's only for displaying the goal which is to use properties on that type that are not in the base.</p>
  
  <pre><code>public void Print(E e)
  {
      Response.Write(e.FirstName);
  }
  
  public void Print(F f)
  {
      Response.Write(f.LastName);
  }
  </code></pre>
  
  <p>I'm curious about how I can get these instructions to work without having to cast the type? In total, I have 4 seperate <code>User</code>s. Each goes through the same process. I'd love to have the code once, not 4 times. This code below will not compile because <code>LastName</code> is not on the <code>User</code> object.</p>
  
  <pre><code>User u = UserFactory.Get("f");
  Print(u);
  </code></pre>