Answers for "c# string capital first letter extension method"

C#
1

c# string capital first letter extension method

public static class StringExtensions
{
    public static string FirstCharToUpper(this string input) =>
        input switch
        {
            null => throw new ArgumentNullException(nameof(input)),
            "" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)),
            _ => input.First().ToString().ToUpper() + input.Substring(1)
        };
}
Posted by: Guest on June-14-2021

Code answers related to "c# string capital first letter extension method"

C# Answers by Framework

Browse Popular Code Answers by Language