Sample for String.Compare(String, Int32, String, Int32, Int32, Boolean), ignore case

image_pdfimage_print
   
  
using System;

class Sample {
    public static void Main() {
        String str1 = "this is a test";
        String str2 = "This is a test";
        String str;
        int result;
    
        result = String.Compare(str1, 2, str2, 2, 2, true);
        str = ((result < 0) ? "less than" : ((result > 0) ? "greater than" : "equal to"));
        Console.Write("Substring &#039;{0}&#039; in &#039;{1}&#039; is ", str1.Substring(2, 2), str1);
        Console.Write("{0} ", str);
        Console.WriteLine("substring &#039;{0}&#039; in &#039;{1}&#039;.", str2.Substring(2, 2), str2);
    
    }
}

   
    
     


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