title: C# Compare two lists, return the new items in list 2
body: <p>This is probable a common question, and I have searched other question without finding a solution that works (note, my skill in C# and linq is limited - so a simple solution would be appreciated!). </p>
  
  <p><strong>Here is the issue</strong>:</p>
  
  <p>I have 2 lists with objects. I want to compare them and return all the NEW objects in list2. </p>
  
  <p><strong>Example:</strong></p>
  
  <p>ObjectList List1; <em>// contains 3 objects that is stored in the database</em></p>
  
  <p>ObjectList List2; <em>// contains the same 3 objects as in List1 and a new object that was added from a webpage (the parent object was updated on the webpage)</em></p>
  
  <p>ObjectList List3; <em>// should do a compare of List1 and List2, and return the NEW objects in List2 (so the result should only be Object number 4)</em></p>
  
  <p><strong>Note:</strong></p>
  
  <ul>
  <li>The order does not matter. I only want the new object(s)</li>
  <li>Normally objects are only added to List2. IF any object is removed (compare to List1), then this should be ignored. (so object that only exists in List1 is of no interest)</li>
  </ul>
  
  <p>Thanks for any suggestions or links to previously questions i missed in my search</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is a small example of first try with Except (this returned an error)</p>
  
  <p>I have shortened it a bit. The method is from our software, so they are probable not know to you. Sorry about that.</p>
  
  <pre><code> // caDialogObjects = List1 (caDialogQLMLinks is the link to the objects)
  RepositoryObjectList caDialogObjects = args.Object.GetConfiguration().GetObjectSet(caDialogQLMLinks);
  
  // caObjectObjects = List2 (caObjectQLMLinks is the link to the objects)
  RepositoryObjectList caObjectObjects = args.Object.GetConfiguration().GetObjectSet(caObjectQLMLinks);
  
  // List 3
  RepositoryObjectList caTotal;
  caTotal = caObjectObjects.Except(caDialogObjects);
  </code></pre>
  
  <p><strong>Solution that worked</strong>
  The Exception did not work since the list is just a reference (not a value). It is possible to use the second parameter, but i got a linq code that worked:</p>
  
  <pre><code>RepositoryObjectList caNewCA = 
      new RepositoryObjectList(caDialogObjects.Where(item1 =&gt; 
           !caObjectObjects.Any(item2 =&gt; item1.Id == item2.Id)));
  </code></pre>