Odd List error
Posted: August 8th, 2012, 10:46 pm
I have:
$lll = new System\Collections\Generic\List<:MvcAppCustomViewEngine\Models\Person:>;
$lll = $model;
$qqq = new System\Collections\Generic\List<:System\String:>;
$qqq->Add("Exit");
$qqq->Add("Exit");
$qqq->Add("Exit");
$d1 = new MvcAppCustomViewEngine\Models\Person;
$d2 = new MvcAppCustomViewEngine\Models\Person;
$d1 = $lll[0];
$d2 = $lll[1];
$pp = new MvcAppCustomViewEngine\Models\Person;
for($i=0; $i<count($lll); ++$i)
{
echo $i." ". $lll[$i]->Name." ".count($lll)." ";
}
foreach($lll as $li) {
$pp=$li;
?>
<li><a href="x"><? echo $pp->Name ?></a><li>
<?
}
echo $lll->Capacity."<<".$lll->Capacity." ".$lll->get_Item(1)->Name." >>>>".$qqq->Count." ".$lll->Count;
Everything works as expected until the last line,
the access of $lll->Count (which is a List of Person where as $qqq is a List
of String), i get a error:
Unable to cast object of type 'System.Collections.Generic.List`1[MvcAppCustomViewEngine.Models.Person]' to type 'System.Collections.Generic.List`1[System.String]'.
this error specifically for the $lll->Count piece of code,
what is odd is it prints the $lll->Capacity, accesses the get_Item(1),
the List of String, it prints its $qqq->Count properly with out error.
I don't understand why $lll->Count is causing a
Unable to cast object of type 'System.Collections.Generic.List`1[MvcAppCustomViewEngine.Models.Person]' to type 'System.Collections.Generic.List`1[System.String]'.
And count($lll) is 1 which is wrong, but the foreach structure does work,
and processed the three Person records in the List.
-tl
$lll = new System\Collections\Generic\List<:MvcAppCustomViewEngine\Models\Person:>;
$lll = $model;
$qqq = new System\Collections\Generic\List<:System\String:>;
$qqq->Add("Exit");
$qqq->Add("Exit");
$qqq->Add("Exit");
$d1 = new MvcAppCustomViewEngine\Models\Person;
$d2 = new MvcAppCustomViewEngine\Models\Person;
$d1 = $lll[0];
$d2 = $lll[1];
$pp = new MvcAppCustomViewEngine\Models\Person;
for($i=0; $i<count($lll); ++$i)
{
echo $i." ". $lll[$i]->Name." ".count($lll)." ";
}
foreach($lll as $li) {
$pp=$li;
?>
<li><a href="x"><? echo $pp->Name ?></a><li>
<?
}
echo $lll->Capacity."<<".$lll->Capacity." ".$lll->get_Item(1)->Name." >>>>".$qqq->Count." ".$lll->Count;
Everything works as expected until the last line,
the access of $lll->Count (which is a List of Person where as $qqq is a List
of String), i get a error:
Unable to cast object of type 'System.Collections.Generic.List`1[MvcAppCustomViewEngine.Models.Person]' to type 'System.Collections.Generic.List`1[System.String]'.
this error specifically for the $lll->Count piece of code,
what is odd is it prints the $lll->Capacity, accesses the get_Item(1),
the List of String, it prints its $qqq->Count properly with out error.
I don't understand why $lll->Count is causing a
Unable to cast object of type 'System.Collections.Generic.List`1[MvcAppCustomViewEngine.Models.Person]' to type 'System.Collections.Generic.List`1[System.String]'.
And count($lll) is 1 which is wrong, but the foreach structure does work,
and processed the three Person records in the List.
-tl