How can I merge two anonymous types, so that the result contains the properties of both source objects?
var source1 = new
{
foo = "foo",
bar = "bar"
}
var source2 = new
{
baz = "baz"
}
var merged = Merge(source1, source2) // <-- here's where the magic should happen
// merged:
// {
// foo = "foo",
// bar = "bar",
// baz = "baz"
// }
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…