Custom Search
Logiclabz
  • Home
  • C#
  • Title case (Proper case) Function in .Net C#

Title case (Proper case) Function in .Net C#

The following function in .Net C# changes the string to its equivalent Title Case.

    public static string ToTitleCase(string mText)
    {
        string rText = "";
        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;
    }



Leave a reply


Do you like this post?