C#首字母大写小写

/// <summary>
/// 首字母小写写
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string FirstCharToLower(this string input)
{
    if (String.IsNullOrEmpty(input))
        return input;
    string str = input.First().ToString().ToLower() + input.Substring(1);
    return str;
}
 
/// <summary>
/// 首字母大写
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string FirstCharToUpper(this string input)
{
    if (String.IsNullOrEmpty(input))
        return input;
    string str = input.First().ToString().ToUpper() + input.Substring(1);
    return str;
}

不要拓展可以把方法参数里的this去掉

求支持我的网站C#首字母大写小写 http://www.494v.com/forum.php?mod=viewthread&tid=253&fromuid=1 (出处: 五秒论坛)

猜你喜欢

转载自blog.csdn.net/qq_38613453/article/details/82728226