Jun 12, 2009

Howto avoid having to use ToUpper() in string comparisons

Instead of using:

if (myString.ToUpper() == theirString.ToUpper) { ... }

Use this:

if( myString.Equals( theirString, StringComparison.OrdinalIgnoreCase ) { ... }


Thanks to: Ralph

No comments:

Post a Comment