Compare strings using StringComparison enumeration : String Compare : String C# Examples


C# Examples » String » String Compare »

 

Compare strings using StringComparison enumeration









    
using  System;    
    
class  MainClass  {    
    public  static  void  Main()  {    
        string  pswd  =  "asdf";    
  
        string  str  =  "fda";  
  
        //  Compare  using  invariant  culture.  
        if(String.Compare(pswd,  str,  
                                            StringComparison.InvariantCulture)  ==  0)  
            Console.WriteLine("Password  accepted.");  
        else    
            Console.WriteLine("Password  invalid.");  
    }  
}
    
   
  
   



Output

Password invalid.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String Compare