Hi all,

I'm not sure if this is by design or not, so hence the post.

I'm assigning an anonymous delegate within a foreach loop and within the 
delegate I'm calling a function and passing a paramater to it. So far 
everything is fine. If I pass a simple string to the called function 
within the delegate, it always holds the last value of the itereration. 
If I pass an object, the passed parameter is correct.


             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);
             }

where Caption is a string property.

I expected both ways to work and I've not tried this sort of thing on 
Windows before hence the question.

So, is this by design?

Dominique.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to