String ToTitleCase extension method C#



We can create ToTitleCase method for string type in c# like below,

public static string ToTileCase(this String str)
{
    if (!string.IsNullOrEmpty(str) && !string.IsNullOrWhiteSpace(str))
        return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(str.ToLower());
    else
      return str;
 }

Example : hello  -> Hello

Labels: String ToTitleCase extension method C#, string extension method, totitlecase extension method string c#, totitlecase method



Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker