Background
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 comes from the DataBoundItem
of the current DataGridViewRow
, using object initializers is therefore not the option i'm looking for and I don't wan't to assign every value from the first object casted from DataBoundItem
again (redundancy).
So my question is: Is it even possible to assign multiple object properties at once and if, how do you achieve it?
Research
I found the following questions, but none of them are solving my problem:
Assigning multiple variables at once in c#
Assign multiple variables at once
Setting multiple properties with one declaration in Windows Forms (C#)
Code
foreach (DataGridViewRow CurrRow in DataGridView.Rows)
{
SomeObject SomeObj = (SomeObject) CurrRow.DataBoundItem;
SomeObj.PropertyA = 0;
SomeObj.PropertyB = 0;
SomeObjCollection.Add(SomeObj);
}
What I have tried
Seperate the properties to assign with comas (Gives a syntax error at the coma):
TimeEntries.Hours, TimeEntries.Expenses = 0;