BestPractice - Transform first character of a string into lower case

前端 未结 11 2018

I\'d like to have a method that transforms the first character of a string into lower case.

My approaches:

1.

public static string ReplaceFir         


        
11条回答
  •  渐次进展
    2020-12-04 12:33

    The fastest solution I know without abusing c#:

    public static string LowerCaseFirstLetter(string value)
    {
        if (value?.Length > 0)
        {
            var letters = value.ToCharArray();
            letters[0] = char.ToLowerInvariant(letters[0]);
            return new string(letters);
        }
        return value;
    }
    

提交回复
热议问题