定义:浅拷贝v。深拷贝 [英] Define: Shallow copy v. Deep copy

查看:82
本文介绍了定义:浅拷贝v。深拷贝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了在线文档,并且我没有找到一个真实的解释,因为上述任何一个或者上面涉及的是什么是

或者exacly他们

的意思。

如果有人能指出我讨论这个话题的正确文件

,我会如此感谢!


thnx,

Christoph

解决方案

来自MS文档对于Object.MemberwiseClone方法:


"浅拷贝创建一个与原始

对象相同类型的新实例,然后复制非原始对象的静态字段。如果

字段是值类型,则执行字段的逐位复制。如果

字段是引用类型,则复制引用但引用的对象

不是;因此,原始对象中的引用和

中的引用克隆指向同一个对象。相比之下,对象的深层副本

重复了

对象中字段直接或间接引用的所有内容。


Ben Lucas

首席开发人员

Solien Technology,Inc。
www.solien.com


" Christoph Boget" < JC ***** @ yahoo.com>在消息中写道

news:uc ************** @ TK2MSFTNGP11.phx.gbl ...

我看了通过在线文档,我无法找到一个真实的解释,以确定什么是上述任何一个或者与他们意味着什么有关。
如果有人可以请指出讨论这个主题的正确文档,我会非常感激!

thnx,
Christoph


我听说在.NET Framwork 2.0中不推荐使用MemberwiseClone()。


-

cody


免费软件工具,游戏和幽默
http://www.deutronium.de.vu || http://www.deutronium.tk

" Ben卢卡斯" < be*@nospam.solien.nospam.com> schrieb im Newsbeitrag

新闻:aN ******************** @ comcast.com ...

来自Object.MemberwiseClone方法的MS文档:

"浅拷贝创建与原始对象相同类型的新实例,然后复制其中的非静态字段原始物体。如果
该字段是值类型,则执行该字段的逐位复制。如果
字段是引用类型,则复制引用但引用的对象不是;因此,原始对象中的引用和克隆中的引用
指向同一个对象。相比之下,对象的深层副本
会复制由
对象中的字段直接或间接引用的所有内容。

Ben Lucas
首席开发人员
Solien Technology,Inc。
www.solien.com

Christoph Boget < JC ***** @ yahoo.com>在消息中写道
新闻:uc ************** @ TK2MSFTNGP11.phx.gbl ...

我查看了在线文档而且我无法找到一个真实的解释,以确定什么是上述任何一个或者与他们意味着什么有关。
如果有人能指出我适当的文档
讨论这个话题,我会非常感激!

thnx,
Christoph




>正如我所听说的那样,在.NET Framwork 2.0中不推荐使用MemberwiseClone()。


被替换为什么?


thnx,

Christoph


I''ve looked through the online documentation and I
couldn''t find a real explanation as to exacly what is
involved with either of the above or exacly what they
mean.
If someone could point me to the proper documentation
that discusses this topic, I''d be ever so appreciative!

thnx,
Christoph

解决方案

From the MS documentation for the Object.MemberwiseClone method:

"A shallow copy creates a new instance of the same type as the original
object, and then copies the non-static fields of the original object. If the
field is a value type, a bit-by-bit copy of the field is performed. If the
field is a reference type, the reference is copied but the referred object
is not; therefore, the reference in the original object and the reference in
the clone point to the same object. In contrast, a deep copy of an object
duplicates everything directly or indirectly referenced by the fields in the
object."

Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Christoph Boget" <jc*****@yahoo.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...

I''ve looked through the online documentation and I
couldn''t find a real explanation as to exacly what is
involved with either of the above or exacly what they
mean.
If someone could point me to the proper documentation
that discusses this topic, I''d be ever so appreciative!

thnx,
Christoph



As I''ve heard MemberwiseClone() will be deprecated in .NET Framwork 2.0.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Ben Lucas" <be*@nospam.solien.nospam.com> schrieb im Newsbeitrag
news:aN********************@comcast.com...

From the MS documentation for the Object.MemberwiseClone method:

"A shallow copy creates a new instance of the same type as the original
object, and then copies the non-static fields of the original object. If the field is a value type, a bit-by-bit copy of the field is performed. If the
field is a reference type, the reference is copied but the referred object
is not; therefore, the reference in the original object and the reference in the clone point to the same object. In contrast, a deep copy of an object
duplicates everything directly or indirectly referenced by the fields in the object."

Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Christoph Boget" <jc*****@yahoo.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...

I''ve looked through the online documentation and I
couldn''t find a real explanation as to exacly what is
involved with either of the above or exacly what they
mean.
If someone could point me to the proper documentation
that discusses this topic, I''d be ever so appreciative!

thnx,
Christoph




> As I''ve heard MemberwiseClone() will be deprecated in .NET Framwork 2.0.

To be replaced with what?

thnx,
Christoph


这篇关于定义:浅拷贝v。深拷贝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆