Connecting Tech Pros Worldwide Help | Site Map

cloning

AVL
Guest
 
Posts: n/a
#1: Nov 19 '05
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????//
Eliyahu Goldin
Guest
 
Posts: n/a
#2: Nov 19 '05

re: cloning


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" <AVL@discussions.microsoft.com> wrote in message
news:EF4FC4D6-9E9F-4C0B-98A1-96C79EF3A96A@microsoft.com...[color=blue]
> Hi,
> I've a query in cloning. How cloning is different from creating a[/color]
new[color=blue]
> 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????//[/color]


Hans Kesting
Guest
 
Posts: n/a
#3: Nov 19 '05

re: cloning


AVL wrote:[color=blue]
> 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????//[/color]

"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


Eliyahu Goldin
Guest
 
Posts: n/a
#4: Nov 19 '05

re: cloning


> "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" <news.2.hansdk@spamgourmet.com> wrote in message
news:%237ND$4c4EHA.2288@TK2MSFTNGP11.phx.gbl...[color=blue]
> AVL wrote:[color=green]
> > 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????//[/color]
>
> "new instance" is "a new empty instance" (or, if you use a constructor
> with parameters, "with (or derived from) these specified values")
>
>
> Hans Kesting
>
>[/color]


Closed Thread