title: Filling collection A according to collection B
body: <p>I have two collections in c#</p>
  
  <pre><code>A: {
        {id:4, name:"", age:1},
        {id:3, name:"", age:3},
        {id:2, name:"", age:5},
  }
  
  B: {
        {id:2, name:"aa"},
        {id:4, name:"bb"},
        {id:3, name:"cc"},
  }
  </code></pre>
  
  <p>I want to fill collection A according to collection B</p>
  
  <pre><code>A: {
        {id:2, name:"aa",age:5},
        {id:4, name:"bb",age:1},
        {id:3, name:"cc",age:3},
  }
  </code></pre>
  
  <p>How can I do this?
  (should I use linq?)</p>
  
  <p>I used:</p>
  
  <pre><code>   private static void FillIsCpHidden(ref Collection A)
          {
              var B= CollectionB.ToDictionary(item =&gt; item.id);
  
              foreach (var item in A)
              {
                  item.name= B[item.id].name;
              }
          }
  </code></pre>