Title Case in c# Winforms.

Peermohamedmydeen
Posted by Peermohamedmydeen under C# category on | Points: 40 | Views : 4013
Hello All,

The below code will be useful when we need to change the text to title case in C# winforms.


Here we are using CultureInfo and TextInfo classes from Globalization Namesapce.

public static string ToTitleCase(string mText)
{
mText = mText.ToLower();
string rtext = string.Empty;

try
{
System.Globalization.CultureInfo cultureinfo = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Globalization.TextInfo textinfo = cultureinfo.TextInfo;
rText = TextInfo.ToTitleCase(mText);

}
catch
{
rText = mText;
}

return rText;
}



I hope it will be helpful.

Thanks
PMM :)

Comments or Responses

Login to post response