c# make static dictionary code example

Example: static dictionary c#

/// <summary>
/// Contains plural logic in static class [separate file]
/// </summary>
static class PluralStatic
{
    /// <summary>
    /// Static string Dictionary example
    /// </summary>
    static Dictionary<string, string> _dict = new Dictionary<string, string>
    {
        {"entry", "entries"},
        {"image", "images"},
        {"view", "views"},
        {"file", "files"},
        {"result", "results"},
        {"word", "words"},
        {"definition", "definitions"},
        {"item", "items"},
        {"megabyte", "megabytes"},
        {"game", "games"}
    };

    /// <summary>
    /// Access the Dictionary from external sources
    /// </summary>
    public static string GetPlural(string word)
    {
        // Try to get the result in the static Dictionary
        string result;
        if (_dict.TryGetValue(word, out result))
        {
            return result;
        }
        else
        {
            return null;
        }
    }
}