To Upper First letter in string - CSharp System

CSharp examples for System:String Case

Description

To Upper First letter in string

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  ww  w.  ja  v  a 2s  .  c om*/

public class Main{
        public static string ToUpperFirst (this string s)
        {
            if (string.IsNullOrEmpty (s)) {
                return string.Empty;
            }
            char[] a = s.ToCharArray ();
            a [0] = char.ToUpper (a [0]);
            return new string (a);
        }
}

Related Tutorials