c# overload resolution rules
问题 suppose the following extension methods: public static string ToFooBarString(this object obj) { ... } public static string ToFooBarString< T >(this IEnumerable< T > obj) { ... } Now i call this over a implementation of the IEnumerable< T > interface, say Dictionary< int , string > f; // implements IEnumerable< KeyValuePair< int , string > > f.ToFooBarString(); // <--- which one is called? which one is called in this case and why? 回答1: The compiler chooses the overload "closest" to the type in