Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ToList on Collection<T>

Tags:

c#

.net

linq

MSDN documentation indicates the the class Collection<T> has a method ToList() in the Extension section.

How I can use this method?

like image 308
dennis Avatar asked Dec 21 '22 09:12

dennis


1 Answers

This documentation is a bit misleading. The type Collection<T> doesn't have this method directly. Intstead it's defined as an extension method on System.Linq.Enumerable. Adding the using directive for System.Linq should fix the problem

using System.Linq; 

...

Collection<T> col = ...;
List<T> list = col.ToList();
like image 129
JaredPar Avatar answered Dec 24 '22 02:12

JaredPar