Comparing a String to the Beginning or End of a Second String : String Compare : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » String Compare »

 

Comparing a String to the Beginning or End of a Second String









    


using System;
using System.Data;
using System.Text.RegularExpressions;
using System.Text;
class Class1{
        static void Main(string[] args){
      string head = "str";
      string test = "strVarName";
      Console.WriteLine(test.StartsWith(head));

      string tail = "Name";
      test = "strVarName";
      Console.WriteLine(test.EndsWith(tail));
        
    
    
      head = "str";
      test = "strVarName";
      Console.WriteLine(string.Compare(head, 0, test, 0, head.Length, true));

      tail = "Name";
      test = "strVarName";
      Console.WriteLine(string.Compare(tail, 0, test, (test.Length - tail.Length), tail.Length, true));
        }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» String Compare