Cerebrus your code is code but if your goal is to convert the array into
generic list then why NOT just use the List.AddRange() ?

On Wed, May 18, 2011 at 12:56 PM, Cerebrus <[email protected]> wrote:

> Generic methods are not usually designed like this. If they had to
> apply cases based on the constructed type, their utility would be very
> limited because it would necessitate adding new code everytime the
> generic method was to be used with a new Type.
>
> In your getList() method, "T" is an open type. When you try to add a
> Product to the list object, it refuses to compile because at that time
> T is not compatible with class Product. Instead, you need to look back
> at the place where you *know* that T is a Product. That place is the
> calling function (Main()) and that should be the place where you
> create and pass on various types of objects to the single generic
> method. This necessitates passing the types as a parameter.
>
> I have posted a modified but simplistic example of your code at
> http://pastebin.com/w7e1Jn6J. Review it and post back if you have
> further doubts.
>
> --
> You received this message because you are subscribed to the Google
> Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
> Web Services,.NET Remoting" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
> or visit the group website at http://megasolutions.net
>

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to