String Clone() - C# Tutorial
C# Course / Strings / String Clone()

String Clone()

BLUF: Mastering String Clone() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Clone()

C# is a powerful, modern language for enterprise solutions. Discover how String Clone() enhances your development workflow in the guide below.

The Clone method in C# is employed to duplicate a string object, producing an additional copy of the existing data. The Clone method's return type is an object.

Signature

Example

public object Clone()

Parameters

It does not take any parameter.

Returns

It returns a reference.

C# String Clone method example

Example

using System;  
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
             string s1 = "Hello ";  
             string s2 = (String)s1.Clone();  
             Console.WriteLine(s1);
             Console.WriteLine(s2);  
        }  
    }

Output:

Output

Hello
Hello

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience