I have a immutable class F1:
public class F1
{
public readonly int field1;
public readonly int field2;
public readonly int field3;
public readonly int field4;
public readonly int field5;
......
public F1 SetField1(int f)
{
return new F1(f, field2, field3, field4, field5);
}
......
}
If i need to change one field, field1 for example, i need to return new instance of class from the method. All five field pass to constructor, even if four of them haven't been changed.
It's ok, if i use 5 fields. But if i use 40 fields and i can't pass 40 parametrs to constructor. What i need to do? How can I save values of other fields and create new instance without passes parameters to constructor?
There is I really need immutable class. It's important condition of my work.