String Manipulation

image_pdfimage_print

   

/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/

 using System;

 namespace StringManipulation
 {
    public class TesterStringManipulationCompare
    {
       public void Run()
       {
           // create some strings to work with
           string s1 = "abcd";
           string s2 = "ABCD";
           int result;  // hold the results of comparisons

           // compare two strings, case sensitive
           result = string.Compare(s1, s2);
           Console.WriteLine(
               "compare s1: {0}, s2: {1}, result: {2}
",
               s1, s2, result);

           // overloaded compare, takes boolean "ignore case"
           //(true = ignore case)
           result = string.Compare(s1,s2, true);
           Console.WriteLine("Compare insensitive. result: {0}
",
               result);

       }

       [STAThread]
       static void Main()
       {
          TesterStringManipulationCompare t = new TesterStringManipulationCompare();
          t.Run();
       }
    }
 }
           
          


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