Aggregation
Aggregate, Average, Count, LongCount, Max, Min, Sum
Conversion
AsEnumerable, Cast, OfType, ToArray, ToDictionary, ToList, ToLookup
Element
ElementAt, ElementAtOrDefault, First, FirstOrDefault, Last, LastOrDefault, Single, SingleOrDefault
ElementAt
ElementAtOrDefault
First (simple)
First (conditional)
FirstOrDefault
Last
LastOrDefault (simple)
LastOrDefault (conditional)
Single
SingleOrDefault
Generation
DefaultIfEmpty, Empty, Range, Repeat
Grouping
GroupBy
Join
GroupJoin, Join
Ordering
OrderBy, OrderByDescending, Reverse, ThenBy, ThenByDescending
OrderBy (simple - numbers)
OrderBy (simple - dates)
OrderBy (simple - objects)
OrderByDescending
Reverse
ThenBy
ThenByDescending
Other
Concat, SequenceEqual, Zip
Partitioning
Skip, SkipWhile, Take, TakeWhile
Projection
Select, SelectMany
Quantifiers
All, Any, Contains
Restriction
Where
Set
Distinct, Except, Intersect, Union
Close
ToList: Converts collection into a List.
ToList: Converts collection into a List. |
ToList: Converts collection into a List. |
This Lambda Expression sample converts string array to List of strings. |
This Lambda Expression sample converts string array to List of strings. |
// A Query Expression cannot be constructed for ToList() in C#. // Consider using a Lambda Expression instead.
' A Query Expression cannot be constructed for ToList() in VB.NET. ' Consider using a Lambda Expression instead.
// A Query Expression cannot be constructed for ToList() in F#. // Consider using a Lambda Expression instead.
static void Sample_ToList_Lambda() { string[] names = { "Brenda", "Carl", "Finn" }; List<string> result = names.ToList(); Debug.WriteLine(String.Format("names is of type: {0}", names.GetType().Name)); Debug.WriteLine(String.Format("result is of type: {0}", result.GetType().Name)); }Output:
names is of type: String[] result is of type: List`1
Private Shared Sub Sample_ToList_Lambda() Dim names As String() = {"Brenda", "Carl", "Finn"} Dim result As List(Of String) = names.ToList() Debug.WriteLine([String].Format("names is of type: {0}", names.[GetType]().Name)) Debug.WriteLine([String].Format("result is of type: {0}", result.[GetType]().Name)) End SubOutput:
names is of type: String[] result is of type: List`1
let Sample_ToList_Lambda() = let names = [|"Brenda"; "Carl"; "Finn"|] let result = names.ToList() Debug.WriteLine(sprintf "names is of type: %s" (names.GetType().Name)) Debug.WriteLine(sprintf "result is of type: %s" (result.GetType().Name))Output:
names is of type: String[] result is of type: List`1