Yep I noticed the "If one generic argument cannot be inferred, all need to be specified", which is a bit of a pain.
I'll mess about with var.... -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Fabian Schmied Sent: 05 December 2007 14:31 To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] type inference and extension methods.... > I discovered this with a more complicated example and used IList as a > simple example....I'm either completely wrong, or the example is too > simple. Maybe you hit the issue where generic arguments used only for a method's return type are not inferred from usage. Like this: public static T Get<T>() { ... } int i = Get<int>(); // needs T to be specified, although "int" could be inferred If one generic argument cannot be inferred, all need to be specified: public static T1 Get<T1, T2>(T2 arg) { ... } int i = Get<int, string> ("xy"); // needs int _and_ string to be specified With an extension method: public static T1 Get<T1, T2>(this IList<T2> list) { ... } IList<string> list; int i = list.Get<int, string>(); // needs int _and_ string to be specified Fabian =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com