title: Edit some elements in c# list
body: <p>I'm trying to edit some elements in a list (called <code>treeNodes</code>):</p>
  
  <pre><code>List&lt;TreeNodeViewModel&gt; treeNodes = GetAllTreeNodes();
  
  foreach (var item in role.Privileges)
  {
      TreeNodeViewModel treeNode = treeNodes.Single(tn =&gt; tn.id == item.Id.ToString());
      treeNode.state.IsChecked = true;
  }
  </code></pre>
  
  <p>But once the <code>treeNode.state.IsChecked = true;</code> is executed, all list items will have <code>IsChecked = true</code>, why is that? It should edit the selected item only.</p>