How do convert a string to lowercase except for the first character? Can this be completed with LINQ?
Thanks
The toLowerCase method converts a string to lowercase letters. The toLowerCase() method doesn't take in any parameters. Strings in JavaScript are immutable. The toLowerCase() method converts the string specified into a new one that consists of only lowercase letters and returns that value.
lower() Return value lower() method returns the lowercase string from the given string. It converts all uppercase characters to lowercase. If no uppercase characters exist, it returns the original string.
In C, the tolower() function is used to convert uppercase letters to lowercase. When an uppercase letter is passed into the tolower() function, it converts it into lowercase. However, when a lowercase letter is passed into the tolower() function, it returns the same letter. Note: In order to use this function, ctype.
C tolower() The tolower() function takes an uppercase alphabet and convert it to a lowercase character. If the arguments passed to the tolower() function is other than an uppercase alphabet, it returns the same character that is passed to the function. It is defined in ctype. h header file.
If you only have one word in the string, you can use TextInfo.ToTitleCase
. No need to use Linq.
As @Guffa noted:
This will convert any string to title case, so, "hello world" and "HELLO WORLD" would both be converted to "Hello World".
To achieve exectly what you asked (convert all characters to lower, except the first one), you can do the following:
string mostLower = myString.Substring(0, 1) + myString.Substring(1).ToLower();
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