I have some rows from a DataGridView that I convert to entity objects. In the conversion process I reset some values. As the \"basic\" data
you can assign them in a chain using the = operator:
TimeEntries.Hours = TimeEntries.Expenses = 0;
as if you would read this statement backwards.
In the case of your loop it would look like this:
foreach (DataGridViewRow CurrRow in DataGridView.Rows)
{
SomeObject SomeObj = (SomeObject) CurrRow.DataBoundItem;
SomeObj.PropertyA = SomeObj.PropertyB = 0;
SomeObjCollection.Add(SomeObj);
}
Important note:
If you are dealing with reference types this will assign only 1 reference to different properties. So that changing one of them will affect all other properties!