Dot Net Perls

Invariant Culture ToUpper, ToLower - C#

by Sam Allen

Problem

What are ToLowerInvariant and related methods for? You want to read a basic discussion about the method and ToUpperInvariant. Words like Invariant are confusing, as is MSDN.

Solution: ToLowerInvariant usage in C#

When programming recently, I encountered ToLowerInvariant and needed to look up information on it. Also, I wanted to know if it was more efficient than the regular ToLower. What's the point of these methods?

What Microsoft says. MSDN states that ToLowerInvariant and ToUpperInvariant are useful only for operating system "identifiers" and only affect behavior with specific locales, such as Turkish.

Method link
String.ToLowerInvariant Method - MSDN
String.ToUpperInvariant Method - MSDN
Char.ToLowerInvariant Method - MSDN

Question: what does it mean for most developers?

Absolutely nothing. The usefulness of these methods is very narrow and they are basically irrelevant to many developers. The documents indicate that these methods will only change behavior with Turkish cultures. Also, on Windows systems, the file system is case-insensitive, which further limits its use.

Conclusion: ToLowerInvariant and related methods in C#

These 'invariant' methods are completely irrelevant to my work as a developer. They have an extremely narrow use with Turkish localizations when you need to uppercase or lowercase a file name.

Not only this, but Windows file systems file handling are case-insensitive, making these methods unlikely to be useful even on a Turkish-localized PC.

Dot Net Perls
About
Sitemap
Strings
IndexOf String Examples
Remove Duplicate Words From...
Remove HTML Tags From String
Replace String Examples
Split String Examples
New
Occurrence Count of String
StartsWith String Examples
© 2008 Sam Allen. All rights reserved.