Compare string : String Compare : String C# Examples


C# Examples » String » String Compare »

 

Compare string









    
using  System;    
    
class  MainClass  {      
    public  static  void  Main()  {      
        string  str1  =  "ABCDEabcde1234567890";      
        string  str3  =  "C#  strings  are  powerful.";      
    
      
        int  result  =  str1.CompareTo(str3);    
        if(result  ==  0)    
            Console.WriteLine("str1  and  str3  are  equal");    
        else  if(result  <  0)    
            Console.WriteLine("str1  is  less  than  str3");    
        else    
            Console.WriteLine("str1  is  greater  than  str3");    
    
    }
}
    
   
  
   



Output

str1 is less than str3


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String Compare