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
ToArray: Converts type to a new array.
ToArray: Converts type to a new array. |
ToArray: Converts type to a new array. |
This Lambda Expression sample converts one array to another. |
This Lambda Expression sample converts one array to another. |
static void Sample_ToArray_Linq() { int[] numbers = { 1, 2, 3, 4 }; var result = from n in numbers.ToArray<int>() select n; Debug.WriteLine("New array contains identical values:"); foreach (int number in result) Debug.WriteLine(number); }Output:
New array contains identical values: 1 2 3 4
Private Shared Sub Sample_ToArray_Linq() Dim numbers As Integer() = {1, 2, 3, 4} Dim result = From n In numbers.ToArray() Select n Debug.WriteLine("New array contains identical values:") For Each number As Integer In result Debug.WriteLine(number) Next End SubOutput:
New array contains identical values: 1 2 3 4
let Sample_ToArray_Linq() = let numbers = [|1; 2; 3; 4|] let result = query { for n in numbers.ToArray<int>() do select n } Debug.WriteLine(sprintf "New array contains identical values:") for number in result do Debug.WriteLine(sprintf "%d" number)Output:
New array contains identical values: 1 2 3 4
static void Sample_ToArray_Lambda() { int[] numbers = { 1, 2, 3, 4 }; var result = numbers.ToArray(); Debug.WriteLine("New array contains identical values:"); foreach (int number in result) Debug.WriteLine(number); }Output:
New array contains identical values: 1 2 3 4
Private Shared Sub Sample_ToArray_Lambda() Dim numbers As Integer() = {1, 2, 3, 4} Dim result = numbers.ToArray() Debug.WriteLine("New array contains identical values:") For Each number As Integer In result Debug.WriteLine(number) Next End SubOutput:
New array contains identical values: 1 2 3 4
let Sample_ToArray_Lambda() = let numbers = [|1; 2; 3; 4|] let result = numbers.ToArray() Debug.WriteLine(sprintf "New array contains identical values:") for number in result do Debug.WriteLine(sprintf "%d" number)Output:
New array contains identical values: 1 2 3 4