Skip to content

Instantly share code, notes, and snippets.

@celestocalculus
Last active November 1, 2018 04:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save celestocalculus/781edee5e0c16a1e9ccf57975e055334 to your computer and use it in GitHub Desktop.
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.
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);
}
}
}
@danielcrenna
Copy link

@celestocalculus Can you attach a license to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment