Pluralizing words in C#.Net

Today I wanted to create a dynamic title of a page according to name of category. Like "My Playlists", "My Libraries" etc. So there is a parameter of categoryID passing to page and I find category object accordingly. So there is a usage of .Net service:

using System.Data.Entity.Design.PluralizationServices; ....
Category category = Category.GetByID(categoryID);
PluralizationService ps = PluralizationService.CreateService(new System.Globalization.CultureInfo("en-GB")); Page.Title = $"My {ps.Pluralize(category.Name)}"; .....

Note: you need to add reference System.Data.Entity.Design to the project.

Comments

Popular posts from this blog

SQLite To MS SQL or Access