Sensitive and insensitive comparison of string:
// you can make use of string.compare() function
// string.compare(string arg1,string arg2,bool IsIgnoreCase)
string s1 = "Hello";
string s2 = "hello";
if (string.Compare(s1, s2, true) == 0)
{
MessageBox.Show("Both strings are Same in insensitive mode");
}
else
{
MessageBox.Show("Both strings are not Same in insensitive mode");
}
if (string.Compare(s1, s2, false) == 0)
{
MessageBox.Show("Both strings are Same in sensitive mode");
}
else
{
MessageBox.Show("Both strings are not Same in sensitive mode");
}
No comments:
Post a Comment