Suppose I have the following:
public record Settings
{
public int Setting1 { get; init; }
}
public record MoreSettings : Settings
{
public string Setting2 { get; init; }
}
...
var settings = new Settings { Setting1 = 1 };
// This is an error - CS0117
MoreSettings moreSettings = settings with { Setting2 = "A string setting" };
Is there a clean way to achieve this? Do I have the syntax wrong?
Obviously, in this contrived case I could just manually copy each base property.
var moreSettings = new MoreSettings { Setting1 = settings.Setting1, Setting2 = "A String!" };
But what if the base record type has lots of properties?