Here is the code to convert any string to Title Case in C#.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;
using System.Net.Mail;
using System.Text.RegularExpressions;
public partial class lSample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strInsName;
strInsName = "hello world";
strInsName = strInsName.ToLower();
strInsName = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(strInsName);
Response.Write(strInsName);
}
}
First we need to convert the string to lower.. Only then the System.Globalization.CultureInfo.CurrentUICulture class will convert the string to Title Case.