See the following recent answer:
https://stackoverflow.com/a/36421418/1017882
To summarise, an extension method has been written that uses generics:
static TResult GetEntry<TEnum, TResult>(this Dictionary<TEnum, string> dictionary, TEnum key) {...}
All works fine when invoked like so:
var attributes = new Dictionary<MyTestEnum, string>();
var result = attributes.GetEntry<MyTestEnum, double>(MyTestEnum.First);
But if I invoke it differently:
var result = attributes.GetEntry(MyTestEnum.First);
Apparently the compiler can no longer infer the types. But it's very clear to see (based on what attributes
is), what type I'm attempting to pass.
Why must I be explicit with what types I pass? It feels like unnecessary code.
Usually questions like this are answered with example usage that would 'break' without this kind of extra info - but I can't think of any scenarios like this.
Bit More Context
The reason I even tried drop that bit of syntax in the first place is because I (vaguely) recall being able to do so with certain generic uses. I wanted to see how it applies with collections like this.