469,291 Members | 1,777 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,291 developers. It's quick & easy.

cloning

AVL
Hi,
I've a query in cloning. How cloning is different from creating a new
instance of an object.? I suppose cloning also creates a new object and
copies the exisitng object's data. Where and when should use cloning????//
Nov 19 '05 #1
3 1551
You should check help on Clone method for a particular class. For example
Clone for String just creates another reference to the same object, no new
object is created. Clone for Image create an exact copy. Clone for DataTable
creates another instance of DataTable with the same schema and constraints
but with no data. All sort of things.

Eliyahu

"AVL" <AV*@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
Hi,
I've a query in cloning. How cloning is different from creating a new instance of an object.? I suppose cloning also creates a new object and
copies the exisitng object's data. Where and when should use cloning????//

Nov 19 '05 #2
AVL wrote:
Hi,
I've a query in cloning. How cloning is different from creating
a new instance of an object.? I suppose cloning also creates a new
object and copies the exisitng object's data. Where and when should
use cloning????//


"new instance" is "a new empty instance" (or, if you use a constructor
with parameters, "with (or derived from) these specified values")

"clone" usually is "a new instance with the SAME contents as the original"

Hans Kesting
Nov 19 '05 #3
> "clone" usually is "a new instance with the SAME contents as the original"
You were right to put cautious "usually". As I responded to the original
post, in case of DataTable the new instance has no data, and in case of
String no new instance is created in the first place.

Eliyahu

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
AVL wrote:
Hi,
I've a query in cloning. How cloning is different from creating
a new instance of an object.? I suppose cloning also creates a new
object and copies the exisitng object's data. Where and when should
use cloning????//


"new instance" is "a new empty instance" (or, if you use a constructor
with parameters, "with (or derived from) these specified values")
Hans Kesting

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tom | last post: by
8 posts views Thread by Tom | last post: by
2 posts views Thread by Hendrik Schober | last post: by
6 posts views Thread by J Williams | last post: by
10 posts views Thread by pazabo | last post: by
1 post views Thread by Dan Dorey | last post: by
reply views Thread by Chris | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.