title: Lambda property value selector as parameter
body: <p>I have a requirement to modify a method so that it has an extra parameter that will take a lambda expression that will be used on an internal object to return the value of the given property. Forgive my probable incorrect use of terminology as this is my first foray into LINQ expressions!</p>
  
  <p>I have tried searching for an answer, but as I mentioned, my terminology seems to be off and the examples I can find are far too complex or deal with expressions for collection functions such as <code>.Where()</code>, which I am familiar with.</p>
  
  <p>What I have so far (cut down version):</p>
  
  <pre><code>class MyClass
  {
      private MyObject _myObject = new MyObject() { Name = "Test", Code = "T" };
  
      private string MyMethod(int testParameter, ??? selector)
      {
          //return _myObject.Name;
          //return _myObject.Code;
          return ???;
      }
  }
  </code></pre>
  
  <p>I would like to call it something like this:</p>
  
  <pre><code>string result = _myClassInstance.MyMethod(1, (x =&gt; x.Name));
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>string result = _myClassInstance.MyMethod(1, (x =&gt; x.Code));
  </code></pre>
  
  <p>Obviously the parts which I am missing is the <code>selector</code> parameter in <code>MyMethod</code>, how to apply it to the local variable and how to pass the required property into the method when I am invoking it.</p>
  
  <p>Any help would be appreciated, also extra bonus points for a VB.NET solutions as well as unfortunately the final implementation needs to be in our lone VB project!</p>