Capitalizes the first character of the given input string. - CSharp System

CSharp examples for System:Char

Description

Capitalizes the first character of the given input string.

Demo Code

//     TelerikAcademy.com. All rights reserved.
using System.Text.RegularExpressions;
using System.Text;
using System.Security.Cryptography;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using System;/* ww  w.j a  va 2  s  . co  m*/

public class Main{
        /// <summary>
        /// Capitalizes the first character of the given input string.
        /// </summary>
        /// <param name="input">Input string.</param>
        /// <returns>Returns the input with the upper first character.</returns>
        public static string CapitalizeFirstLetter(this string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                return input;
            }

            return input.Substring(0, 1).ToUpper(CultureInfo.CurrentCulture) + input.Substring(1, input.Length - 1);
        }
}

Related Tutorials