Get Title, Capitalizes the first letter of every word - CSharp System

CSharp examples for System:String Case

Description

Get Title, Capitalizes the first letter of every word

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;//  www . j  av  a 2 s.  c o  m

public class Main{
        //Capitalizes the first letter of every word
        //the big story -> The Big Story
        public static string GetTitle(string input)
        {
            string[] words = input.Split(new char[] { ' ' });

            for (int i = 0; i < words.Length; i++)
            {
                if (words[i].Length > 0)
                    words[i] = words[i].Substring(0, 1).ToUpper() + words[i].Substring(1);
            }

            return String.Join(" ", words);
        }
}

Related Tutorials