[mono-android] What´s wrong with this piece of code?
Leighton Haynes
leighton.haynes at gmail.com
Fri Mar 11 07:50:54 EST 2011
I seem to recall that this line:
IList<IDictionary<string, object>> groupData = new List<
Dictionary<string, object>>() as IList<IDictionary<string, object>>;
will fail as List<Dictionary> will not cast to IList<IDictionary>. Which
means that curGroupMap is null. I haven't thrown it at a compiler to check
though.
Cheers,
Leighton...
On Fri, Mar 11, 2011 at 8:36 PM, Carlo Bolz <cb at dm-edv.de> wrote:
> Hello,
>
>
>
> what´s wrong with this piece of code:
>
>
>
> IList<IDictionary<string, object>> groupData = new List<
> Dictionary<string, object>>() as IList<IDictionary<string, object>>;
>
> IList<IList<IDictionary<string, object>>> childData = new List
> <List<Dictionary<string, object>>>() as IList<IList<IDictionary<string,
> object>>>;
>
>
>
> for (int i = 0; i < 20; i++)
>
> {
>
> IDictionary<string, object> curGroupMap = new Dictionary<
> string, object>();
>
> curGroupMap.Add(NAME, "Group " + i.ToString());
>
> curGroupMap.Add(ISEVEN, (i % 2 == 0) ? "This group is
> even" : "This group is odd");
>
> groupData.Add(curGroupMap); // < the app dies here
>
>
>
> IList<IDictionary<string, object>> children = new List<
> Dictionary<string, object>>() as IList<IDictionary<string, object>>;
>
> for (int j = 0; j < 15; j++)
>
> {
>
> IDictionary<string, object> curChildMap = new
> Dictionary<string, object>();
>
> curChildMap.Add(NAME, "Child " + j.ToString());
>
> curChildMap.Add(ISEVEN, (j % 2 == 0) ? "This child is
> even" : "This child is odd");
>
> children.Add(curChildMap);
>
> }
>
> childData.Add(children);
>
> }
>
>
>
> Any suggestions?
>
>
>
> Mit freundlichem Gruß / With kind regards
>
> Carlo Bolz
>
> [image: E-Mailfooter]
>
>
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110311/e69e8ffa/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 12034 bytes
Desc: not available
Url : http://lists.ximian.com/mailman/private/monodroid/attachments/20110311/e69e8ffa/attachment-0001.jpe
More information about the Monodroid
mailing list