title: Extension method for strongly typed property access
body: <p>I have the following class hierarchy</p>
  
  <pre><code>class Test
  {
      public string Name { get; set; }
  }
  
  class TestChild : Test
  {
      public string Surname { get; set; }
  }
  </code></pre>
  
  <p>I <strong>can't</strong> change the Test class. I want to write following extension method like this:</p>
  
  <pre><code>static class TestExtensions
  {
      public static string Property&lt;TModel, TProperty&gt;(this Test test, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; property)
      {
          return property.ToString();
      }
  }
  </code></pre>
  
  <p>To be able to use it in the following way:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          TestChild t = new TestChild();
          string s = t.Property(x =&gt; x.Name);
      }
  }
  </code></pre>
  
  <p>But now compiler says </p>
  
  <blockquote>
    <p>The type arguments for method 'ConsoleApplication1.TestExtensions.Property(ConsoleApplication1.Test, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.</p>
  </blockquote>
  
  <p>I want to have something like mvc Html.TextBoxFor(x => x.Name) method. 
  Is it possible to write extension to be used as shown in the <code>Main</code> method?</p>