interface property copy in c#

后端 未结 8 2206
一生所求
一生所求 2021-02-07 08:13

I\'ve been working with C# for many years now, but just come across this issue that\'s stumping me, and I really don\'t even know how to ask the question, so, to the example!

8条回答
  •  梦如初夏
    2021-02-07 08:58

    I don't believe there's a language ready solution for this (all the properties would need to have getters and setters).

    You could create Address as an abstract class, with a Copy(Address add) method.

    Alternatively, you could make Home and Work to HAVE an IAddress, and not extend one. The copy would then be immediate.

提交回复
热议问题