Comparing Strings:
Syntax:
Compare( string strA, string strB )
Description:
Compares two specified string objects and returns an integer that indicates their relative position in the sort order.
using System;
namespace StringApplication
{
class StringProg
{
static void Main(string[] args)
{
string str1 = "This is test";
string str2 = "This is text";
if (String.Compare(str1, str2) == 0)
{
Console.WriteLine(str1 + " and " + str2 + " are equal.");
}
else
{
Console.WriteLine(str1 + " and " + str2 + " are not equal.");
}
Console.ReadKey() ;
}
}
}
Result:
This is test and This is text are not equal.
No comments:
Post a Comment