title: Pass a property of a class as a parameter?
body: <p>I need to pass in a property of a class which is used twice in an extension method, to check for duplicate values in this property.</p>
  
  <pre><code>public static class MatchedProductsExtensionMethods
  {
      public static bool IdenticalValues(this List&lt;Product&gt; matchedProducts)
      {
          var itemToMatch = matchedProducts.First();
          if (matchedProducts.All(p =&gt; p.PROPERTYTHATCANCHANGE == itemToMatch.PROPERTYTHATCANCHANGE))
              return true;
          else
              return false;
      }
  }
  </code></pre>
  
  <p>So I need to be able to pass in the name of a property of the <code>Product</code> class and then that replaces <code>PROPERTYTHATCANCHANGE</code>. For example, the properties in the <code>Product</code> class could be <code>ProdName</code> or <code>ProdUsers</code> and then I would need to check to see if there are items in the <code>matchedProducts</code> list which have the same values for these properties.</p>
  
  <p>Thanks in advance!</p>