title: Split field a string and compare each value with string linq c#
body: <p>I'm trying to search in DataTable with three string columns[start_date, end_date, expected_visits] using LINQ, but the third column has many lines as shown</p>
  <p><a href="https://i.stack.imgur.com/R5phb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R5phb.png" alt="date_columns" /></a></p>
  <p>So I split the third one with <code>\n</code> but I want to loop over date to compare it with text of txtSearchYear and return the result as DataTable, When I tried to use ForEach as shown in my code, An error appeared with me says <code>A local or parameter named 'e' cannot be declared in this scope because that name is used in an enclosing local scope to define a local</code> here is my code ...</p>
  <pre><code>var tblResult =
      tbl
          .AsEnumerable()
          .Where(x =&gt;
              x.Field&lt;string&gt;(&quot;start_date&quot;).Substring(0, 4).Equals(txtSearchYear.Text.Trim())
              || x.Field&lt;string&gt;(&quot;end_date&quot;).Substring(0, 4).Equals(txtSearchYear.Text.Trim())
              || x.Field&lt;string&gt;(&quot;expected_visits&quot;).Split('\n').ToList().ForEach((e) =&gt;
              {
                  e.Substring(0, 4).Equals(txtSearchYear.Text.Trim())
              }));
  
  if (tblResult.Any())
  {
      GetData(tblResult.CopyToDataTable());
  }
  else
  {
      DGVData.Rows.Clear();
  }
  </code></pre>