Different types of String Compare methods
public class
Example
{
public static void Main()
{
string testString1 = "String1";
string testString2 = "String2";
if (testString1.CompareTo(testString2) == 0) //or 1
{
//Condition
}
if (testString1.Equals(testString2))
{
//Condition
}
if (testString1 == testString2)
{
//Condition
}
Console.ReadLine();
}
}
No comments:
Post a Comment