Make name Plural - CSharp System.Globalization

CSharp examples for System.Globalization:English

Description

Make name Plural

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Collections.Specialized;
using System.Collections.Generic;

public class Main{
        public static string MakePlural(string name)
        {/*from  w w w .jav a2  s  .  c o  m*/
            if (name.EndsWith("ch") || name.EndsWith("s"))
                name += "es";
            else if (name.EndsWith("y") && !name.EndsWith("ay"))
                name = name.Substring(0, name.Length - 1) + "ies";
            else
                name += "s";

            return name;
        }
}

Related Tutorials