title: Comparing Two lists of Different Objects without for loop
body: <p>I have two lists:</p>
  
  <pre><code>List&lt;ObjA&gt; AList;
  List&lt;ObjB&gt; BList;
  </code></pre>
  
  <p>Now I have a method to compare individual <code>Obj A</code> to <code>Obj B</code>:</p>
  
  <pre><code>void CompareObjAToObjB(ObjA a, ObjB b)
  {
     ....
  }
  </code></pre>
  
  <p>where it asserts the individual elements of objects by comparing them. For now, I did by sorting the two lists using an unique identifier and then iterate the sorted list through a <code>for</code> loop and calling the <code>Compare</code> method.</p>
  
  <p>Is there a better way to compare the lists using a Lambda expression or Linq?</p>
  
  <pre><code>Edit
  </code></pre>
  
  <p>ok. Here is My original code..</p>
  
  <pre><code> Alist.sort((x,y) =&gt; string.Compare(x.acctNumber, y.acctNumber));
   Blist.sort((x,y) =&gt; string.Compare(x.acctNumber, y.acctNumber));
  
   for(int i =0; i&lt; Alist.count; i++)
   {
        CompareObjAToObjB(Alist[i], Blist[i]);
   }
  </code></pre>
  
  <p>Alist contains the repo Object that I input where as BList is a Object that returns by a Service API call. Both contains the same data but in different structures.</p>