T
Tony Johansson
Hello!
In VS 2003 I almost certain that it wasn't possible to update a collection
with foreach because it was readonly.
Now in VS 2008 it seems to me that it possible to update by using foreach.
Below I have a collection named paramList that I first update by using a for
loop and that works fine.
Then I update by using a foreach and that too works just fine.
List<WorksheetRowParameter> paramList = MyParameterResult.Where(p =>
p.WorksheetRowID == wsrID).ToList();
for(int k = 0; k< paramList.Count(); k++)
paramList[k].WorksheetRowID = myPreviousWorksheetRowID;
foreach(WorksheetRowParameter wsrp in paramList)
wsrp.WorksheetRowID = myPreviousWorksheetRowID;
So just give me a comment about if it's poosible to use a foreach whan
update a collection
//Tony
In VS 2003 I almost certain that it wasn't possible to update a collection
with foreach because it was readonly.
Now in VS 2008 it seems to me that it possible to update by using foreach.
Below I have a collection named paramList that I first update by using a for
loop and that works fine.
Then I update by using a foreach and that too works just fine.
List<WorksheetRowParameter> paramList = MyParameterResult.Where(p =>
p.WorksheetRowID == wsrID).ToList();
for(int k = 0; k< paramList.Count(); k++)
paramList[k].WorksheetRowID = myPreviousWorksheetRowID;
foreach(WorksheetRowParameter wsrp in paramList)
wsrp.WorksheetRowID = myPreviousWorksheetRowID;
So just give me a comment about if it's poosible to use a foreach whan
update a collection
//Tony