Created
March 24, 2013 23:05
-
-
Save visoft/5233986 to your computer and use it in GitHub Desktop.
String extensions to make pluralization, etc. easier. Inspiration for these came from Ruby on Rails.
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
using System; | |
using System.Data.Entity.Design.PluralizationServices; | |
using System.Globalization; | |
namespace VisoftInc.Common.Extensions | |
{ | |
public static class StringExtensions | |
{ | |
public static string ToTitleCase(this string value) | |
{ | |
return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(value); | |
} | |
public static String Pluralize(this String s) | |
{ | |
return PluralizationService.CreateService(CultureInfo.CurrentCulture).Pluralize(s); | |
} | |
public static String Singularize(this String s) | |
{ | |
return PluralizationService.CreateService(CultureInfo.CurrentCulture).Singularize(s); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment