ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

Pleuralise

A simple method that adds 's' onto words. used when you return x record(s)

Source

public static string PleuraliseByAddingS(this string input, int number)
{
    if (!String.IsNullOrEmpty(input))
    {
        if (number == 1) return input;

        return string.Format("{0}s", input);
    }
    else
    {
        return null;
    }

}

Example

There are PleuraliseByAddingS("record",10) will add an 's' onto record.

Author: Russell Holmes

Submitted on: 17 dec. 2014

Language: C#

Type: Russell Holmes

Views: 4326