How to use C# string Clone


CSharp.Net-Informations.com
SiteMap

Clone() method creates and returns a copy of string object. The CSharp string Clone() method returns a reference to this instance of string.

Object String.Clone()

Returns:

Object : Return the instance of the String


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);
            }
        }
    }
}

When you run this C# program you will get the same content of the first string "Clone() Test"


  • Sponsored Program








More Source Code :
|  Home  |   VB.NET  |   C#  |   ASP.NET  |   SiteMap  |   Terms of Use  |   About  |