On 05.11.2011 10:26, Dominique Louis wrote:
> Robert inside the constructor of StringElement(), item.Key and
> se.Caption are exactly the same value.
>
> I'm still no 100% this is by design, unless you were joking.

You didn't answer my question. It's crucial to know if you
were using the loop variable ("item") inside the delegate,
as this is the only source of such problems.

See Eric Lippert's article. He's one of the C# fathers
and he's definitely not joking:

http://blogs.msdn.com/b/ericlippert/archive/2009/11/12/closing-over-the-loop-variable-considered-harmful.aspx

Robert


>
> D.
>
> On Sat, 05 Nov 2011 01:01:33, Robert Jordan<[email protected]>  wrote:
>> 04.11.2011 23:48, Dominique Louis wrote:
>>>                 foreach (KeyValuePair<string, int>    item in murderStats)
>>>                 {
>>>                     var se = new StringElement(item.Key,
>>> item.Value.ToString());
>>>                     se.Tapped += delegate {
>>>                         StatisticsDrillDownMap( se ); // This works...
>>>                         StatisticsDrillDownMap( se.Caption ); // This does
>>> NOT work, and only holds the last item.Key
>>>                     };
>>>                     sec.Add(se);
>>>                 }
>> Could it be that you wanted to write that
>>
>>      StatisticsDrillDownMap(item.Key)
>>
>> doesn't work? Indeed, this is by design.
>>
>> Robert
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>


-- 
:: AMMMa AG
:: Fon: +49 521 96878-0   mailto:[email protected]
:: Fax: +49 521 96878-20  http://www.ammma.de
:: Firmensitz: Ritterstr. 19, 33602 Bielefeld
:: Registergericht: Amtsgericht Bielefeld, HRB 36772
:: Vorstand: Olaf Schneider, Robert von Donop
:: Vorstandsvorsitzender: Volker Wittenbröker
:: Aufsichtsratsvorsitzender: Karl-Hermann Böker
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to