Linq Example 20 - ToList

10:53 PM
Linq Query:

//list
            int[] Numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            var Sorted =
                from s in Numbers
                orderby s descending
                select s;

            List  SortedArrayList = Sorted.ToList();

            foreach (int t in SortedArrayList)
            {
                Console.WriteLine(t);
            }


Output:


10
9
8
7
6
5
4
3
2
1

0 comments:

Post a Comment