Re: Generic method & constraint
- From: timor.super@xxxxxxxxx
- Date: Mon, 11 Feb 2008 05:46:15 -0800 (PST)
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
.
- Follow-Ups:
- Re: Generic method & constraint
- From: Marc Gravell
- Re: Generic method & constraint
- References:
- Generic method & constraint
- From: timor . super
- Re: Generic method & constraint
- From: Jon Skeet [C# MVP]
- Re: Generic method & constraint
- From: timor . super
- Re: Generic method & constraint
- From: Jon Skeet [C# MVP]
- Re: Generic method & constraint
- From: timor . super
- Re: Generic method & constraint
- From: Marc Gravell
- Re: Generic method & constraint
- From: Marc Gravell
- Generic method & constraint
- Prev by Date: Re: Generic methods help
- Next by Date: Re: Socket class, connect to an endpoint with port 21
- Previous by thread: Re: Generic method & constraint
- Next by thread: Re: Generic method & constraint
- Index(es):