Code Samples

Code Samples

Convert First letter of each word in a string to upper case–ASP.NET

If you want to convert the first letter of each word in a sentence to capital letter, what we did earlier was to split the string to words, change starting letter of each word to Upper case and then join them. This will be helpful when you display names.

Here is a simplest way to do that in ASP.NET

System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(kr);

Sample

string sample = "hello world";
Response.Write(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(sample));

Output

Hello World

blog comments powered by Disqus