471,571 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,571 software developers and data experts.

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 1631
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
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.