Many people don't realize that they can compare strings using: OrdinalIgnoreCase instead of having to do someString.ToUpper().
This removes the additional string allocation overhead.
if( myString.ToUpper() == theirString.ToUpper() )
{ ... }
becomes
if( myString.Equals( theirString, StringComparison.OrdinalIgnoreCase )
{ ... }
Or you can use:
"string".equals("String", StringComparison.InvariantCultureIgnoreCase);
No comments:
Post a Comment