Created
April 8, 2018 17:24
-
-
Save gte445e/8983bb557b633b705558e89ac065fa80 to your computer and use it in GitHub Desktop.
Title Case String extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Globalization; | |
using System.Threading; | |
namespace System | |
{ | |
public static class StringExtensions | |
{ | |
public static string ToTitleCase(this string value) | |
{ | |
if (value == null) return null; | |
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; | |
TextInfo textInfo = cultureInfo.TextInfo; | |
return textInfo.ToTitleCase(value.ToLower()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment