calling ToList. : ToList « LINQ « C# / C Sharp






calling ToList.

 

using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {

        var numbers = new List<int>() { 1, 2 };

        List<int> timesTen = numbers
          .Select(n => n * 10)
          .ToList();
        numbers.Clear();
        Console.WriteLine(timesTen.Count);
    }
}

 








Related examples in the same category

1.Calling the ToList Operator
2.Convert Query result to a List
3.Convert an ArrayList to an IEnumerable That Can Be Used with the Typical Standard Query Operators