First Character of String Lowercase - C#
This will work:
string s = "ConfigService";
if (s != string.Empty && char.IsUpper(s[0]))
{
s = char.ToLower(s[0]) + s.Substring(1);
}
Console.WriteLine(s);
One way:
string newString = oldString;
if (!String.IsNullOrEmpty(newString))
newString = Char.ToLower(newString[0]) + newString.Substring(1);
For what it's worth, an extension method:
public static string ToLowerFirstChar(this string input)
{
if(string.IsNullOrEmpty(input))
return input;
return char.ToLower(input[0]) + input.Substring(1);
}
Usage:
string newString = "ConfigService".ToLowerFirstChar(); // configService
You could try this:
lower = source.Substring(0, 1).ToLower() + source.Substring(1);