title: Linq to join two similar object list?
body: <pre><code>objA = new obj()
  {
      ID = 123,
      attriA = "",
      attriB = "someValueB"
  }
  
  objB = new obj()
  {
      ID = 123,
      attriA = "someValueA",
      attriB = ""
  }
  
  List&lt;obj&gt; ListA = new List&lt;obj&gt;();
  ListA.add(objA);
  
  List&lt;obj&gt; ListB = new List&lt;obj&gt;();
  ListB.add(objB);
  </code></pre>
  
  <p>Given the above scenario, I need to have <code>listC</code> with the below object:</p>
  
  <pre><code>objC = new obj()
  {
      ID = 123,
      attriA = "someValueA",
      attriB = "someBalueB"
  }
  </code></pre>
  
  <p>This is what I've tried. It worked but I'm thinking there must be ways to shorten the code by using linQ which I have no idea:</p>
  
  <pre><code>foreach(obj item in ListA)
  {
      obj objB = ListB.Where(x=&gt; x.ID == item.ID).FirstOrDefault();
  
      obj objC = new obj(){
          ID = objB.ID;
          attriA = item.attriA;
          attriB = objB.attriB;
      };
      ListC.add(objC);
  }
  </code></pre>