I have an object with a number of properties.
I want to be able to assign some of these properties when calling the constructor.
The obvious solution is to either have a constructor that takes a parameter for each of the properties, but it is nasty when there are lots. Another solution would be to create overloads, each of which accepts a subset of the property values, but I could get dozens of overloads.
So, I thought it would be nice if I could say.
MyObject x = new MyObject(o => o.Property1 = "ABC", o.PropertyN = xx, ...);
The problem is that I'm too dull to work , how to do it.
Did you know?
source
share