title: Lambda ForEach with Index
body: <p>Here are a list of column names:</p>
  
  <pre><code>var colNames = new List&lt;string&gt; { "colE", "colL", "colO", "colN" };
  </code></pre>
  
  <p>Based on the position of the column names in the list, I want to make that column's visible index equal to the position of the column name, but without returning a list. In other words, the following lambda expression without "ToList()" at the end:</p>
  
  <pre><code>colNames.Select((x, index) =&gt; { grid_ctrl.Columns[x].VisibleIndex = index; return x; }).ToList();
  </code></pre>
  
  <p>Can this be coded in a one-line lambda expression?</p>