Re: Generic method & constraint

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On 11 fév, 14:36, "Marc Gravell" <marc.grav...@xxxxxxxxx> wrote:
What you have works!???

Oops; I've just tried in 2005 (I use 2008 normally) - and the
type-inference differences (not to mention the LINQ "ToArray") are
making a difference. Apologies for confusion if you are using 2005
(and the message that appears in 2005 is not necessarily obvious).

So; either specify the type-arguments manually, or use C# 3 which does
a better job here...

With the signature:
static void Write<TList,T>(IEnumerable<TList> list) where TList :
IEnumerable<T> {...}

you can use (in VS2005):

Write<List<int>,int>(list);
Write<List<string>,string>(list2);

Ok, I understand better

thanks all for your answer

Best regard
.