This is a difficult question to google!
I have an extension method that takes "Enum" as a parameter.
public static T GetEntry<T>(this Dictionary<Enum, string> dictionary, Enum key)
{
string val;
if (dictionary.TryGetValue(key, out val))
{
return (T)Convert.ChangeType(val, typeof(T));
}
return default(T);
}
but when I try to use it with a declared enum the compiler can't find the extension method
Dictionary<CmdAttr, String> Attributes;
cmd.CommandText.Attributes.GetEntry<double>(CommandText.CmdAttr.X);
Any idea how to make this work other than to declare the dictionary as
Dictionary<Enum, String> Attributes
which works but kind of defeats the point in having a declared enum?
Many Thanks