Beware of anonymous delegates in C#! You’ve to instanize new variable to have them in own delegate instances. If not, you’ll get the last value of variable in loop.
Short snippet for Gtk#. It creates dynamic buttons and actions from DataTable (e.g. database). Pay attention to line // [1], when „variable capturing” is used.
[csharp]
foreach(DataRow g in groups.Rows)
{
DataRow tmp = g; // [1]
Button b = new Button(g[„name”].ToString());