String copy and equal

image_pdfimage_print

   
  
/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/
 using System;

 namespace StringManipulation
 {
    public class TesterStringCopyEqual
    {
       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);

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

           // member method
           Console.WriteLine(
               "
Does s6.Equals(s5)?: {0}",
               s6.Equals(s5));

           // static method
           Console.WriteLine(
               "Does Equals(s6,s5)?: {0}",
               string.Equals(s6,s5));

           // overloaded operator
           Console.WriteLine(
               "Does s6==s5?: {0}", s6 == s5);
       }

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


           
         
    
     


This entry was posted in Data Types. Bookmark the permalink.