Home > General > Pluralize words

Pluralize words

Whenever I’ve needed the plural form of a word, I’ve always relied on the Inflector class from the Castle ActiveRecord project.

string plural = Inflector.Pluralize("planet");
Console.WriteLine (plural);

Since .NET 4.0, Microsoft has added their own PluralizationService class to pluralize words. Microsoft’s PluralizationService class is actually used in the Entity Framework tools to generate singular or plural entity names.

var service = PluralizationService

string plural = service.Pluralize("planet");

There are cases when both classes do not generate the same plural form of a word. For example, attempting to pluralize the word “virus” generates different results. Inflector will return “viri” while the PluralizationService will return “virus”. Neither generated the more common “viruses”.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: