Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Plural to Singular and vice-versa
Message
De
10/01/2007 10:25:59
 
 
À
09/01/2007 18:07:25
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01183997
Message ID:
01184181
Vues:
14
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform