title: Generic C# function to check duplicates (different objects, different fields)
body: <p>I want to create a generic function the gets three arguments (a List of objects, a property name and a value) ... the function has to check for duplicates.
  So :</p>
  
  <pre><code>class A  {
     public string description;
     public string abbreviation;
  }
  
  class B {
     public string description;
     public string name;
  }
  </code></pre>
  
  <p>I have two List objects ... one with multiple class A objects and one with multiple class B objects.</p>
  
  <pre><code>List &lt;A&gt; listOfA
  List &lt;B&gt; listOfB
  </code></pre>
  
  <p>I want a function called with something like this :</p>
  
  <pre><code>bool hasDuplicateAbbreviation = CheckDuplicate (listOfA, "abbreviation", "ALG");
  bool hasDuplicateName = CheckDuplicate (listOfB, "name", "Mrs. Smith");
  bool hasDuplicateDescription = CheckDuplicate (listOfB, "description", "Nice toolkit");
  </code></pre>
  
  <p>How should I do this ?</p>
  
  <p>Nice to have would be if the same function could also be used for a class C with an integer rank :</p>
  
  <pre><code>class C  {
     public string description;
     public int rank;
  }
  
  List &lt;C&gt; listOfC
  
  bool hasDuplicateRank = CheckDuplicate (listOfC, "rank", 2);
  </code></pre>