P
Peter Morris
var result = new List<StockLevelRow>();
foreach(SomeClass c in SomeList)
result.Add(
new StockLevelRow(c.Name,
delegate() { return c.StockLevel; },
delegate(int value) { c.StockLevel = value; }
)
);
This is a PITA because the last variable assigned to "c" is captured by each
of the two delegates. Is there a simple workaround for this? If not then I
am going to have to make my StockLevelRow class abstract and create a
concrete descendant for each different way I have of obtaining/setting the
StockLevelRow.Quantity (which currently uses a get and set delegate passed
to it).
Thanks
Pete
foreach(SomeClass c in SomeList)
result.Add(
new StockLevelRow(c.Name,
delegate() { return c.StockLevel; },
delegate(int value) { c.StockLevel = value; }
)
);
This is a PITA because the last variable assigned to "c" is captured by each
of the two delegates. Is there a simple workaround for this? If not then I
am going to have to make my StockLevelRow class abstract and create a
concrete descendant for each different way I have of obtaining/setting the
StockLevelRow.Quantity (which currently uses a get and set delegate passed
to it).
Thanks
Pete
