Char
implements the methods ToLowerInvariant
and ToUpperInvariant
to transform a character to upper/lower case independent of the current culture. However, there are no IsUpperInvariant
and IsLowerInvariant
methods. Why?
Asked
Active
Viewed 165 times
2

Tommaso Belluzzo
- 23,232
- 8
- 74
- 98

James Ko
- 32,215
- 30
- 128
- 239
-
As a workaround, you can write one yourself. – Sweeper Dec 28 '17 at 03:34
-
What would they return? True if ToUpperInvariant/ToLowerInvariant would return itself? – Eric MSFT Dec 28 '17 at 04:22
-
1I think the short answer is that it's not needed enough to make it into mscorlib, and `c == Char.ToLowerInvariant(c)` is only few characters more than `Char.IsLowerInvariant(c)`. Also, if it's added for `IsLower`, it will probably have to be added to most of the other `Char.Is` methods – Slai Dec 28 '17 at 04:29
1 Answers
2
The following methods are the best you can get:
Once a character is converted to lower/upper format, whether the conversion was culture specific or not, they will properly detect its case.
On the other hand, you cannot say if a given character is the product of a culture specific or an invariant transformation. You can just look at it and observe that its current case is either lower or upper. Given, for example, the character E
obtained from an upper case transformation... how can you say if it originally was ë
or e
? If you don't know it's original form and the current culture the system is using... you simply can't.

Tommaso Belluzzo
- 23,232
- 8
- 74
- 98