ExtensionMethod.NET Home of 829 C#, Visual Basic, F# and Javascript extension methods


Returns the plural form of the specified word.


/// <summary>
/// Returns the plural form of the specified word.
/// </summary>
/// <param name="count">How many of the specified word there are. A count equal to 1 will not pluralize the specified word.</param>
/// <returns>A string that is the plural form of the input parameter.</returns>
public static string ToPlural(this string @this, int count = 0)
    return count == 1 ? @this : System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(new System.Globalization.CultureInfo("en-US")).Pluralize(@this);


"goose".ToPlural(); // returns "geese"
"wolf".ToPlural(); // returns "wolves"

String.Format("{0} {1}", commentCount, "comment".ToPlural(commentCount)); // returns "1 comment" or "2 comments"

Author: Shawn Miller

Submitted on: 3 feb 2011

Language: C#

Type: System.String

Views: 6259