title: Unable to cast object of type 'System.DateTime' to type 'System.String'” error
body: <p>I have this code: </p>
  
  <pre><code> public bool GetHolidays(DataSet ds,List&lt;string&gt; dates,DataTable dt)
      {
          for (int i = 0; i &lt;= dates.Count; i++)
          {
              bool weekOff = ds.Tables[0].AsEnumerable().Where(x=&gt;(x.Field&lt;string&gt;("WeekOffDays")==dates[i]).ToString()).Any(); // error in this line
  
              if(weekOf)
                 return true;
  
              return false;
          }
       }
  </code></pre>
  
  <p>I get the error that says:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.DateTime' to type 'System.String'</p>
  </blockquote>
  
  <p>To overcome this I tried: </p>
  
  <pre><code>   DateTime dateTime;
     bool weekOff = ds.Tables[0].AsEnumerable().Where(x=&gt;DateTime.TryParse((x.Field&lt;string&gt; 
       ("WeekOffDays")==dates[i]).ToString(),out dateTime)).Any(); 
  </code></pre>
  
  <p>but still the error persists.</p>
  
  <p>I tried with DateTime but when I write it, it gives me another error saying</p>
  
  <blockquote>
    <p>Operator == cannot be used for DateTime and string</p>
  </blockquote>
  
  <p><strong>Please note:</strong> The column <strong>WeekOffDays</strong> is of type <strong>datetime</strong></p>
  
  <p>How this can be solved?</p>