Odd List error
2 posts
• Page 1 of 1
Odd List error
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
- tleslie
- Posts: 32
- Joined: August 3rd, 2012, 4:42 am
Re: Odd List error
Thanks for the test case. I've successfully reproduced the error, so we can fix it into upcoming release.
Just note: count() does not work with IList or IDictionary objects yet, so it returns always 1 instead of real Count. But we will probably implement that, since it is more intuitive.
Just note: count() does not work with IList or IDictionary objects yet, so it returns always 1 instead of real Count. But we will probably implement that, since it is more intuitive.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 14 guests