开发者

Whats a "shallow copy" of an objects [duplicate]

开发者 https://www.devze.com 2023-02-10 01:16 出处:网络
This question already has answers 开发者_运维百科here: Closed 11 years ago. Possible Duplicate: What is the difference between a deep copy and a shallow copy?
This question already has answers 开发者_运维百科here: Closed 11 years ago.

Possible Duplicate:

What is the difference between a deep copy and a shallow copy?

I saw this today here: http://msdn.microsoft.com/en-us/library/system.web.routing.route.aspx and one of the member functions was:

"MemberwiseClone - Creates a shallow copy of the current Object. (Inherited from Object.)"

So whats a "shallow copy" verse a ... "Deep copy"?


Shallow copy only replaces the properties on the current level of the object, that means if you have an object as a property it will have the same reference as your original. This is not a problem if your properties are value types or primitives of course.

0

精彩评论

暂无评论...
验证码 换一张
取 消