Net-informations.com
SiteMap  | About    

How to use C# string Clone

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"




net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.