Ağu 26 2009

How to Capitalize the First Letter of Each Words in a string in C#

Category: C#Latif @ 16:24

Hi,

İf you wonder as to how to capitalize simply first letter of each words in a string, you can use ToTitleCase.

Check the sample below,

using System;

using System.Globalization;

 

namespace ToTitleCaseApp

{

    class Program

    {

        static void Main(string[] args)

        {

            string capitalizedFirstLetter = CultureInfo.CurrentCulture.TextInfo.ToTitleCase("shoot for the moon. even if you miss, you'll land among the stars.");

            Console.WriteLine(capitalizedFirstLetter);

            Console.ReadKey();

        }

    }

}

 

Result :

Shoot For The Moon. Even If You Miss, You'll Land Among The Stars.

I think, it is a handy method.

have a good time!

Tags: ,