Is it possible to have delegates declared in a loop perform different actions?
var buttons = new List<ImageButton>();
buttons.Add(FindViewById<ImageButton>(Resource.Id.button1));
buttons.Add(FindViewById<ImageButton>(Resource.Id.button2));
int count = 1;
foreach(var button in buttons) {
button.Click += delegate {
Toast.MakeText(this, "I am " + count, ToastLength.Short).Show();
}
count++;
}
The toast message always "I am 2" when clicking either button. Ultimately I would like to have a number of buttons performing slightly different actions when clicked.