hi
how to notice if "abcDEf"
different that "abcdef"
?
in C# winforms ?
thank's in advance
hi
how to notice if "abcDEf"
different that "abcdef"
?
in C# winforms ?
thank's in advance
bool aredifferent = "abcDEf" != "abcdef";
//OR
string str1 = "abcDEf", str2 = "abcdef";
bool aredifferent2 = str1 != str2;
.NET string equality operator is case sensitive, so simply using it will return false if string differ in case.
If, however, you are looking to determining if two strings are the same, but only differ in case, then you could use something like this:
bool differInCase = string.Compare(str1, str2, /*ignoreCase=*/true) == 0 &&
string.Compare(str1, str2, /*ignoreCase=*/false) != 0;;
Since you're in Winforms, i'm assuming you're using System^ String. They come with an "Equals" member to take care of this situation.
http://msdn.microsoft.com/en-us/library/1hkt4325.aspx
System::String::Equals( str1, str2 )
This returns a System::Boolean which is true/false.
Edit Sorry, i've been doing Winforms in C++ for too long..here's C#
System.String.Equals(a, b)
Still returns a System Boolean which is true/false.
Edit Edit
If you're looking to do a Current culture case-insensitive equal's check:
System.String.Equals(a,b,System.StringComparison.CurrentCultureIgnoreCase)
Check this MSDN page for all the info on the StringComparison enumeration:
http://msdn.microsoft.com/en-us/library/system.stringcomparison.aspx
Are you looking for something like this?
function IsLowerCase(String input)
{
return input.Equals( input.ToLower() );
}
This function will return false if the input string is in mixed or upper case. If instead the input string is in lower case then it will return true.