title: c# foreach into LINQ expression
body: <p>I have been using foreach statement and resharpen suggested that i use LINQ instead. This is what i came up with but i'm getting error. Can someone give me a hand with this:</p>
  
  <p><strong>Question 1:</strong>
  Foreach statement:</p>
  
  <pre><code>List&lt;string&gt; captured = new List&lt;string&gt;();
  foreach (DataRow row in table.Rows)
      captured.Add(row["ID"].ToString());
  </code></pre>
  
  <p>attempt LINQ Statement</p>
  
  <pre><code>var captured2 = table.Rows.ToList().ForEach(row =&gt; { captured.Add(row["ID"].ToString());});
  </code></pre>
  
  <p><strong>Question 2:</strong></p>
  
  <p>Also i got this compound statement too which i have no clue on how to create the LINQ statement</p>
  
  <pre><code>        List&lt;string&gt; captured = new List&lt;string&gt;();
          foreach (DataRow row in table.Rows)
          {
              foreach (DataColumn col in table.Columns)
              {
                  if (!col.ToString().Equals("Name") || !col.ToString().Equals("ID"))
                      captured.Add(row[col.ToString()].ToString());
              }
          }
  </code></pre>
  
  <p>Thanks</p>