Faced a problem: I need to initialize the base class with minimal code writing, because it can expand or change in the future and I don’t want to go into the constructor every time and change / add field assignments.
I think the code will better express my thought) I need it to be like this:
class Base { public Base(Base b) { this = b; // <--- Так не работет а очень хотелось бы } public int field1 { get; set; } public int field2 { get; set; } } class Child: Base { /// Конструктор потомка public Child(Base b, int field3) : base(b) { this.field3 = field3; } public int field3 { get; set; } } field2 you have to manually assign values for field1 and field2 ? something like that:
/// Конструктор потомка public Child(Base b, int field3) { this.field1 = b.field1; this.field2 = b.field2; this.field3 = field3; } Is there not a wordy and effective way to solve this problem?
You can of course apply the auto-chopper, but can there be a way to solve this problem in c # style without frills and reflections?