Last active
November 1, 2018 04:47
-
-
Save celestocalculus/781edee5e0c16a1e9ccf57975e055334 to your computer and use it in GitHub Desktop.
.NET Core is new and is missing a couple of important extension functions. As I create them for my current code (on a "as I discover them" basis), I'll update this gist.
This file contains 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
namespace Tiketmobile.Helpers | |
{ | |
public static class StringHelper | |
{ | |
public static string ToTitleCase(this TextInfo textInfo, string str) | |
{ | |
var tokens = str.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); | |
for (int i = 0; i < tokens.Length; i++) | |
{ | |
var token = tokens[i]; | |
tokens[i] = token.Substring(0, 1).ToUpper() + token.Substring(1); | |
} | |
return string.Join(" ", tokens); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@celestocalculus Can you attach a license to this?