Explain current thinking around IClonable.

Answer Posted / madhunathanv

*-->ICloneable is to create the copy of type instances.

*-->To create a true copy of a reference type,
you must clone the object to which it refers.

*-->The ICloneable interface identifies a type as cloneable
and declares the Clone method as the
mechanism through which you obtain a clone of an object.
*-->The Clone method takes no arguments
and returns a System.Object, regardless of the implementing
type. This means that once you clone
an object, you must explicitly cast the clone to the
correct type.


*-->If your custom type contains reference-type data
members, you must decide whether your Clone method will
perform a shallow copy or a deep copy.
*--> A shallow copy means that any referencetype
data members in the clone will refer to the same objects as
the equivalent reference-type data
members in the original object.
*--> A deep copy means that you must create clones of the
entire object graph so that the reference-type data members
of the clone refer to physically independent copies
(clones) of the objects referenced by the original object.

Note:Mostly Shallow Copy is being Preferred.Because A
shallow copy is easy to implement by calling the
MemberwiseClone method from within your
Clone method.
System.Xml.XmlNode implements
a deep copy in its Clone method

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What tags do you need to add within the asp:datagrid tags to bind columns manually? How?

514


What is is post back property in asp net?

540


Explain the difference between server control and html control.

476


How do cookies work?

594


Write a code snippet to implement the indentation in json in web api.

576






Can we use html in asp.net?

502


In order to get assembly info which namespace we should import?

525


Explain the advantages of caching?

532


Explain a program using code nuggets to create a simple application? : asp.net mvc

510


Just by seeing the signature of the bean how can you specify whether it is a stateful or stateless session bean?

553


What is viewstate? What does the "enableviewstate” property do? Whay would I want it on or off?

527


Define data caching?

545


What is the difference between adding reference in solution explorer and adding references by using ?

576


Which is the parent class of the ASP.NET server control?

541


What r the asp.net list controls and diff. Between them?

507