.Net Deep cloning - what is the best way to do that?

前端 未结 7 2181
小蘑菇
小蘑菇 2020-12-05 20:39

I need to perform deep cloning on my complex object model. What do you think is the best way to do that in .Net?
I thought about serializing / Deserializing
no need

7条回答
  •  不知归路
    2020-12-05 21:08

    The best way is probably to implement the System.IClonable interface in your object and all its fields that also needs custom deep cloning capabilities. Then you implement the Clone method to return a deep copy of your object and its members.

提交回复
热议问题