Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 4.0: Is it possible to call ConvertAll for IList<>?

'ConvertAll' is not implemented for IList, Am I right? Is there any workaround?

Thanks.

like image 419
Budda Avatar asked Dec 06 '10 04:12

Budda


2 Answers

IList<T> does not define a method called ConvertAll(). You can see the definition here: http://msdn.microsoft.com/en-us/library/5y536ey6.aspx

There is a method on the concrete implementation List<T>; http://msdn.microsoft.com/en-us/library/73fe8cwf.aspx

You can replicate this behaviour using the LINQ statement .Select().

like image 175
Alastair Pitts Avatar answered Nov 07 '22 09:11

Alastair Pitts


You will have to use a System.Collections.Generic.List to have a .ConvertAll() method in the base.

IList does not implement .ConvertAll().

If you MUST use an IList, you could always write your own .ConvertAll() method.

like image 36
Flipster Avatar answered Nov 07 '22 09:11

Flipster