title: Select and ForEach on List<>
body: <p>I am quite new to C# and was trying to use lambda expressions. </p>
  
  <p>I am having a list of object. I would like to select item from the list and perform foreach operation on the selected items. I know i could do it without using lambda expression but wanted to if this was possible using lambda expression.</p>
  
  <p>So i was trying to achieve a similar result</p>
  
  <pre><code>        List&lt;UserProfile&gt; users = new List&lt;UserProfile&gt;();
         ..load users with list of users
          List&lt;UserProfile&gt; selecteditem = users.Where(i =&gt; i.UserName=="").ToList();
          foreach(UserProfile item in selecteditem)
          {
              item.UserName = "NA";
          }
  </code></pre>
  
  <p>it was possible to do</p>
  
  <pre><code>      users.Where(i =&gt; i.UserName=="").ToList().ForEach(i=&gt;i.UserName="NA");
  </code></pre>
  
  <p>but not something like this</p>
  
  <pre><code>     users.select(i =&gt; i.UserName=="").ForEach(i=&gt;i.UserName="NA");
  </code></pre>
  
  <p>Can someone explain this behaviour..</p>