string s = "h"; s = s.ToUpper();
returns "H"
.
string s = "8"; s = s.ToUpper();
returns "8"
Should this not return "*"
?
In C#, ToUpper() is a string method. It converts every characters to uppercase (if there is an uppercase version). If a character does not have an uppercase equivalent, it remains unchanged. For example, special symbols remain unchanged.
In C#, the Toupper() function of the char class converts a character into uppercase. In the case that we will be discussing, only the first character of the string needs to be converted to uppercase; the rest of the string will stay as it is.
ToUpper converts all characters to uppercase characters. It causes a copy to be made of the VB.NET String, which is returned. Here We look at ToUpper and its behavior. This console program shows the result of ToUpper on the input String "abc123".
The ToUpper method is often used to convert a string to uppercase so that it can be used in a case-insensitive comparison. A better method to perform case-insensitive comparison is to call a string comparison method that has a StringComparison parameter whose value you set to StringComparison.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With