Create a string by copying from another in CSharp

Description

The following code shows how to create a string by copying from another.

Example


 using System;//from w w w  . ja v a  2 s.c om

 namespace StringManipulation
 {
    public class TesterStringManipulationCopy
    {
       public void Run()
       {
           string s1 = "abcd";
           string s2 = "ABCD";

           // the string copy method
           string s5 = string.Copy(s2);
           Console.WriteLine(
               "s5 copied from s2: {0}", s5);

           // use the overloaded operator
           string s6 = s5;
           Console.WriteLine("s6 = s5: {0}", s6);
       }

       static void Main()
       {
          TesterStringManipulationCopy t = new TesterStringManipulationCopy();
          t.Run();
       }
    }
 }

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var