.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Convert to Title Case Format from string values

Posted By:Ravi Ranjan Kumar       Posted Date: June 30, 2011    Points: 200    Category: C#    URL: http://www.dotnetspark.com  

This article enable you to convert string value to Title case

Title case means each and every single character of words is capital as Title has normally. we can accomplish this task by using System.Globalization; namespace having "TextInfo" class.

Take a look how to convert string to Title Case 

at first Import Globalization Namespace to access all needed class like "TextInfo" class through out the program  as

using System.Globalization;
after that we can use given code/ method to convert string to Title Case

  public string ConvertTitleCase(string str)
            TextInfo txtinfo = CultureInfo.CurrentCulture.TextInfo;
            return txtinfo.ToTitleCase(str);

About Function

 ConvertTitleCase taking one parameter as string datatype and it's return type is also string. This function will able to take string value in normal way and returns it as Title Case as "dot net spark" to Dot Net Spark"

 Take a Look how

Enter string value in textBox1 and then click on button1 you will see textBox2 will hold formated output. 

private void button1_Click(object sender, EventArgs e)
            textBox2.Text = ConvertTitleCase(textBox1.Text);

How program will look


References Link :-

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend