Generic C# Copy Constructor

前端 未结 5 1378
再見小時候
再見小時候 2021-01-31 10:55

What would be the best way to write a generic copy constructor function for my c# classes? They all inherit from an abstract base class so I could use reflection to map the prop

5条回答
  •  走了就别回头了
    2021-01-31 11:08

    Avoid reflection if you can. Each class should have the responsibility of copying its own properties, and send it further to the base method.

提交回复
热议问题