Uppers the case of the first char. - CSharp System

CSharp examples for System:String Case

Description

Uppers the case of the first char.

Demo Code


using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text;
using System;//w ww. j  a v  a 2  s.  co  m

public class Main{
        /// <summary>
        /// Uppers the case of the first char.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static string UpperCaseFirstChar(string name)
        {
            if (name.Length >= 1 && char.IsLower(name[0]))
            {
                char[] chars = name.ToCharArray();
                chars[0] = Char.ToUpper(chars[0]);
                return new string(chars);
            }
            return name;
        }
}

Related Tutorials