How can I make the first character of a string lowercase?
For example: ConfigService
And I need it to be like this: configService
This will work:
public static class StringExtensions
{
[CanBeNull]
public static string FirstCharToLowerCase([CanBeNull] this string str)
{
if (string.IsNullOrEmpty(str) || char.IsLower(str[0]))
return str;
return char.ToLower(str[0]) + str.Substring(1);
}
}
(This code arranged as "C# Extension method")
Usage:
myString = myString.FirstCharToLowerCase();