title: Compare 2 Lists and Create New List with Different Items
body: <p>I have two Lists that I'm trying to compare.  What I need to accomplish is essentially to remove the items that are duplicated between the two lists and only keep the objects that are different.  Right now, I'm inserting the non-duplicate data into a new list.</p>
  
  <p>The data I'm using here...</p>
  
  <p>LIST1
  ("b",2)
  ("c",3)</p>
  
  <p>LIST2
  ("a",1)
  ("b",2)
  ("c",3)
  ("d",4)</p>
  
  <p>NEWLIST
  ("a",1)
  ("d",4)</p>
  
  <p>Here's what I have so far...</p>
  
  <p>My object:</p>
  
  <pre><code>public class TestClass
  {
      protected string teststring;
      protected int testint;
  
      public string TestString
      {
          get { return teststring; }
          set { teststring = value; }
      }
      public int TestInt
      {
          get { return testint; }
          set { testint = value; }
      }
  
      public TestClass() { }
  }
  </code></pre>
  
  <p>My compare logic:</p>
  
  <pre><code>private static List&lt;TestClass&gt; CompareCodes(List&lt;TestClass&gt; list1, List&lt;TestClass&gt; list2)
  {
      List&lt;TestClass&gt; newList = new List&lt;TestClass&gt;();
      foreach (TestClass s in list2)
      {
          if (list1.Contains(s) == false)
          {
              newList.Add(s);
          }
      }        
  
      if (newList.Count != 0)
          return newList;
      else
          return null;
  }
  </code></pre>
  
  <p>The new list will be used to insert data into a database table.  If it's null, no action will be taken.  I'm using .NET 2.0 in this app (it's an enhancement to an older app), so I can't use LINQ.  So is there any other way to make this work that I'm missing?  Or is there a better way to do this?  I haven't been able to find anything (maybe just not looking hard enough) to accomplish what I'm trying to do.</p>
  
  <p>Thanks in advance!</p>