Home > Code > String Operations > String comparisons using C#.NET string.compareTo

String comparisons using C#.NET string.compareTo

by Thamilselvanj   on Nov 14, 2010   Category: String Operations   |  Views: 289    |  Points: 25   |  Silver 



class Program
{
static void Main(string[] args)
{
string strFirstString = "Sample";
string strSecString = "Simple";
if (strFirstString.CompareTo(strSecString)==0)
{
Console.WriteLine("Both strings are same");
}
else
{
Console.WriteLine("Both strings are not same");
}
Console.ReadKey();

}
}



Like this code? Bookmark and Share:

  User Responses | Post Code
 No Response found!
  Recent Posts
* Setting focus to textbox control using JavaScript (308) by Narain_Siddharth on Nov 13 2010 11:25AM
* Sending Mails with Attachements using Asp.Net (361) by Narain_Siddharth on Nov 13 2010 11:48AM
* Disable the Submit button when insert or update a record using JavaScript (277) by Narain_Siddharth on Nov 13 2010 12:31PM
* String comparisons using C#.NET string.compareTo (289) by Thamilselvanj on Nov 14 2010 11:16AM
* String.Split using C# (286) by Thamilselvanj on Nov 14 2010 11:23AM
  Submit feedback about this code snippet
Please sign in to post feedback