I have a string like this LUXOR and I want to convert other letters to lowercase except first letter or the string.that meant, I want this string Luxor from above string. I can convert full string to upper or lower by using ToUpper
or ToLower
.but how can I do this.hope your help with this.thank you
tolower() function in C/C++ If the character passed is an uppercase alphabet then the tolower() function converts an uppercase alphabet to a lowercase alphabet. int tolower(int ch);
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.
So yes, just loop through the string and convert each character to lowercase. for ( ; *p; ++p) *p = tolower(*p); seems more idiomatic.
lower() is a built-in Python method primarily used for string handling. The . lower() method takes no arguments and returns the lowercased strings from the given string by converting each uppercase character to lowercase. If there are no uppercase characters in the given string, it returns the original string.
You can make use of TextInfo
class that Defines text properties and behaviors, such as casing, that is specific to a writing system.
string inString = "LUXOR".ToLower();
TextInfo cultInfo = new CultureInfo("en-US", false).TextInfo;
string output = cultInfo.ToTitleCase(inString);
This snippet will give you
Luxor
in the variableoutput
. this can also be used to capitalize Each Words First Letter
Another option is using .SubString, for this particular scenario of having a single word input:
string inString = "LUXOR"
string outString = inString.Substring(0, 1).ToUpper() + inString.Substring(1).ToLower();
Try This,
string inString = "LUXOR";
string output = inString.Substring(0, 1) + inString.Substring(1).ToLower();
string inString2 = "HI HOW ARE YOU";
string[] finalstring = inString2.Split(' ');
string output2 = string.Empty;
foreach (var item in finalstring)
{
if (output2 == "")
{
output2 = (item.ToUpper().Substring(0, 1) + item.ToLower().Substring(1));
}
else
{
output2 += " " + (item.ToUpper().Substring(0, 1) + item.ToLower().Substring(1));
}
}
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