title: Simple LINQ and List error: WhereListIterator`1[Task]' to type 'System.Collections.Generic.List`1[Task]'
body: <p>I'm having trouble understanding my error</p>
  
  <p>Method:</p>
  
  <pre><code>public List&lt;Task&gt; GetAllTasks()
  {
      var AllTasks = from t in tasks
                     where t.Status.ToString() == "Completed" || t.Status.ToString() == "Pending"
                     select t;
  
      return (List&lt;Task&gt;)AllTasks;
  }
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      TaskList tdl = (TaskList)Session["TodoList"];
      List&lt;Task&gt; AllTasks = tdl.GetAllTasks();
      string str = "";
  
      foreach (Task t in AllTasks)
      {
          str += t.ToString() + "&lt;br /&gt;";
      }
  
      LblTasks.Text = str;
  
  }
  </code></pre>
  
  <p>After I add a task (AddTask.aspx) I redirect to another page to display them, then I get the runtime error: </p>
  
  <p>Unable to cast object of type 'WhereListIterator<code>1[Task]' to type 'System.Collections.Generic.List</code>1[Task]'.</p>
  
  <p>Is there something wrong with my LINQ? I just learned yesterday hehe.</p>
  
  <p>Thanks.</p>