Skip to content

Instantly share code, notes, and snippets.

@visoft
Created March 24, 2013 23:05
Show Gist options
  • Save visoft/5233986 to your computer and use it in GitHub Desktop.
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.
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