I have the following class:
public class Employees {
public string field1 { get; set; }
public string field2 { get; set; }
public string field3 { get; set; }
public string field4 { get; set; }
}
And i want to change values to all those members. so i can to something like that:
Employees.field1 = "ghgf";
Employees.field2 = "ghgf";
Employees.field3 = "ghgf";
Employees.field4 = "ghgf";
but it's very ugly. and the amount of members will be 30, so this is not a good way... I want to use for loop, that run over all the members and dynamic took the relevant field and change the value. for example:
for(int i=1; i<4; i++) {
var field = "field" + i;
Employees.field(the Var!!) = "fgdfd";
}
but in this line:
Employees.field(the Var!!) = "fgdfd";
I have a problem because field is the var that was defined in the for loop.
List<Employees>here. That would make it easier to operate and manipulate and also give you 30 individual objects in aList.