title: remove duplicate items from list in c#
body: <p>I have list of class of type</p>
  
  <pre><code>public class MyClass
  {        
      public SomeOtherClass classObj;         
      public string BillId;           
  }
  
  public List&lt;MyClass&gt; myClassObject;
  </code></pre>
  
  <p>Sample Values:</p>
  
  <pre><code>BillId = "123",classObj = {},
  BillId = "999",classObj = {},
  BillId = "777",classObj = {},
  BillId = "123",classObj = {}
  </code></pre>
  
  <p>So in above example, we have duplicate values for <code>BillId</code>. I would like to remove all the duplicate values (Not Distinct) so the result would contain only <code>999</code> &amp; <code>777</code> value.</p>
  
  <p>One way to achieve this to </p>
  
  <ul>
  <li>Loop through all items</li>
  <li>Get count of unique <code>BillId</code></li>
  <li>If count is greater than 1, store that <code>BillId</code> in another variable</li>
  <li>Loop again and remove item based on <code>BillId</code></li>
  </ul>
  
  <p>Is there any straightforward way to achieve this?</p>