81
LINQ ToList() Method
In LINQ, the ToList operator takes the element from the given source, and it returns a new List. So, in this case, input would be converted to type List.
Syntax of LINQ ToList() operator
The syntax of using the LINQ ToList() to convert the input collection to list.
C# Code
In the above syntax, we are converting “countries” collection to list using the LINQ ToList() operator.
Example of ToList() operator in method syntax
The example of using the LINQ ToList() to convert the input collection to List in method syntax.
C# Code
OUTPUT:
In the above example, we are converting countries collection to List by using the LINQ ToList() method.
Example of ToList() operator in Query Syntax
The example of using the LINQ ToList() operator in Query Syntax
OUTPUT:
Next TopicLINQ ToArray() Method