Uppercase first letter of a string in C#

To uppercase the first letter of a string in C#, use:

public string UppercaseFirst(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            char[] a = s.ToCharArray();
            a[0] = char.ToUpper(a[0]);

            return new string(a);
        }

Example

Input : bhaumik Patel

Output : Bhaumik Patel
Uppercase first letter of a string in C# Uppercase first letter of a string in C# Reviewed by Bhaumik Patel on 1:27 AM Rating: 5