cloning

G

Guest

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????//
 
E

Eliyahu Goldin

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
 
H

Hans Kesting

AVL said:
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
 
E

Eliyahu Goldin

"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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top