Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Plural to Singular and vice-versa
Message
From
10/01/2007 10:25:59
 
 
To
09/01/2007 18:07:25
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01183997
Message ID:
01184181
Views:
13
Hey Craig!

>If last character = 's'
> Add 'es'
>else
> Add 's'
>Endif

yeah, I wrote a little fancier than that:
if (text.EndsWith("y"))
{
  plural = text.Substring(0, text.Length - 1) + "ies";
}
else if (text.EndsWith("ch") || text.EndsWith("x"))
{
  plural = text + "es";
 }
else
{
   plural = text + "s";
}
Claudio Lassala
Previous
Reply
Map
View

Click here to load this message in the networking platform