c# how to initiate dictionary in static class code example
Example: static dictionary c#
static class PluralStatic
{
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"}
};
public static string GetPlural(string word)
{
string result;
if (_dict.TryGetValue(word, out result))
{
return result;
}
else
{
return null;
}
}
}