What is the use of clone method and also its types?
what is use of clone method and its types
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 7, 2013, 6:38 PM EST
using System;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
string str = "Clone() Test";
string clonedString = null;
clonedString = (String)str.Clone();
MessageBox.Show (clonedString);
}
}
}
}
Please refer the below links
http://csharp.net-informations.com/string/csharp-string-clone.htm
http://www.codeproject.com/Articles/3441/Base-class-for-cloning-an-object-in-C
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 7, 2013, 8:37 PM EST
Hi,
Clone() in C# is implemented by ICloneable interface.
The resulting clone must be of the same type as or a compatible type to the original instance.
with the help of Clone you can create a new object of the same type as the one you invoke it on, without knowing the exact type of the object you are invoking it on.
hope this will help you.
VulpesRank #55 · 29.2K reputationPosted Feb 8, 2013, 1:08 AM EST