title: How can I pass different types of list<T> into a method for grouping by similar fields
body: <p><strong>I would like to create a generic method that will accept lists of different types with similar fields that I can group by.</strong></p>
  
  <p>For instance, I have two lists:  </p>
  
  <pre><code> - List&lt;MemberPurchases&gt; Purchases 
   - List&lt;MemberReturns&gt; Returns
  </code></pre>
  
  <p>I want a method that will accept both of the different types of lists and then group them by a similar field: (Purchases.MemberID or Returns.MemberID).</p>
  
  <p><strong>Here is what I have, but it won't let me do any linq queries on the list when passed in:</strong></p>
  
  <pre><code>Public static int GetMemberActivity&lt;T&gt;(List&lt;T&gt; memberList)
  {
      var groupedList = memberList.GroupBy(x =&gt; x.  
  }
  </code></pre>
  
  <p>At that point I only get four options (which none of them are the elements in the list):</p>
  
  <ol>
  <li>Equals</li>
  <li>GetHashCode</li>
  <li>GetType</li>
  <li>ToString</li>
  </ol>
  
  <p><strong>What I'm looking for is:</strong></p>
  
  <pre><code>var groupedList = memberList.GroupBy(x =&gt; x.MemberID);
  </code></pre>
  
  <p>How can I fix this so I can pass in any list that has the MemberID element and group by it via LINQ.</p>