Reputation: 469
string s = "h";
s = s.ToUpper();
returns "H"
.
string s = "8";
s = s.ToUpper();
returns "8"
Should this not return "*"
?
Upvotes: 30
Views: 7166
Reputation: 980
ToUpper()
to following Text:
"there are 8 buildings"Upvotes: 1
Reputation: 723719
No, it shouldn't. ToUpper()
doesn't mean WithShiftKeyOnAnInternationalASCIIKeyboard()
. There isn't an uppercase 8, as 8 is a number, not a letter.
Of course, this is a gross over-simplification (being a number alone doesn't automatically make a certain character in a character set caseless), but it's likely what you're asking for anyway so I'll leave it at that.
Upvotes: 93
Reputation: 1375
The real answer is because the TextInfo associated with the CultureInfo for en-US does not define "*" as the uppercase of "8".
It may be possible to extend that TextInfo, override toUpper(), and have it work like you wish.
Upvotes: 6
Reputation: 17858
Just because you press shift 8 to get a * doesnt make it an uppercase value, it only applies for a-z characters.
Upvotes: -1
Reputation: 499042
Because there is no upper case 8
.
Just because the specific keyboard you are using has a *
on the same key as the 8
, doesn't mean that all keyboards do. Some languages do not have upper case letter - what should ToUpper
return for those?
This method uses the casing rules of the current culture to convert each character in the current instance to its uppercase equivalent. If a character does not have an uppercase equivalent, it is included unchanged in the returned string.
Upvotes: 28