title: Match and update values using linq from two lists?
body: <p>Hi I am new to the c# and <code>Linq</code>. I am trying to update the one list if the value of some property matches the value of the other lists property.</p>
  
  <p>Suppose i have one list as <code>firstlist</code> </p>
  
  <pre><code>   Name      code        
     ABC       101         
     DEF       201         
     GHI       301
     JKL       401
     MNO       101 
  </code></pre>
  
  <p>And Second list as <code>secondlist</code></p>
  
  <pre><code>  description       Code
      IT               101
      ADMIN            201
      Develeopment     301
      Testing          401
      Service          501
  </code></pre>
  
  <p>And i want my resultant list as </p>
  
  <pre><code>    Name      code        
      ABC       101 IT        
      DEF       201 ADMIN       
      GHI       301 Develeopment
      JKL       401 Testing
      MNO       101 IT
  </code></pre>
  
  <p>I tried something like  this , </p>
  
  <pre><code>    var query = firstlist.Select(x =&gt; { x.Code = 101; return x.Code.ToString()+"IT"; })
  </code></pre>
  
  <p>But i want to match the code from the <code>secondlist</code> in place of <code>101</code> and for matching code i want to update the <code>firstlist</code> code with the <code>code+description</code> i don't have any idea how to do it if anyone suggest any way or link which will guide me would be great.</p>
  
  <p><em><strong></em>**<em>*</em>****</strong><em>UPDATE</em><strong><em>*</em>**<em>*</em>***</strong></p>
  
  <p>What i want to say is that as @Sergey suggested </p>
  
  <pre><code>   from x in firstlist
     join y in secondList
     on x.code equals y.Code
     select new {
         x.Name,
        code = String.Format("{0} {1}", y.Code, y.description)   
    }
  </code></pre>
  
  <p>in place of this can i just do something like this</p>
  
  <pre><code>   from x in firstlist
     join y in secondList
     on x.code equals y.Code
     select x.code = String.Format("{0} {1}", y.Code, y.description)   
  </code></pre>
  
  <p>which will only update the existing <code>listone</code> in place of the creating new entity for each match </p>