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
Zip: Processes two collections in parallel with func instance, and combines result into a new collection.
Zip: Processes two collections in parallel with func instance, and combines result into a new collection. |
Zip: Processes two collections in parallel with func instance, and combines result into a new collection. |
This Lambda Expression sample uses Zip to process two arrays in parallel, while each processed pair is summed. |
This Lambda Expression sample uses Zip to process two arrays in parallel, while each processed pair is summed. |
// A Query Expression cannot be constructed for Zip() in C#. // Consider using a Lambda Expression instead.
' A Query Expression cannot be constructed for Zip() in VB.NET. ' Consider using a Lambda Expression instead.
// A Query Expression cannot be constructed for Zip() in F#. // Consider using a Lambda Expression instead.
static void Sample_Zip_Lambda() { int[] numbers1 = { 1, 2, 3 }; int[] numbers2 = { 10, 11, 12 }; var result = numbers1.Zip(numbers2, (a, b) => (a * b)); Debug.WriteLine("Using Zip to combine two arrays into one (1*10, 2*11, 3*12):"); foreach (int number in result) Debug.WriteLine(number); }Output:
Using Zip to combine two arrays into one (1*10, 2*11, 3*12): 10 22 36
Private Shared Sub Sample_Zip_Lambda() Dim numbers1 As Integer() = {1, 2, 3} Dim numbers2 As Integer() = {10, 11, 12} Dim result = numbers1.Zip(numbers2, Function(a, b) (a * b)) Debug.WriteLine("Using Zip to combine two arrays into one (1*10, 2*11, 3*12):") For Each number As Integer In result Debug.WriteLine(number) Next End SubOutput:
Using Zip to combine two arrays into one (1*10, 2*11, 3*12): 10 22 36
let Sample_Zip_Lambda() = let numbers1 = [|1; 2; 3|] let numbers2 = [|10; 11; 12|] let result = numbers1.Zip(numbers2, fun a b -> (a * b)) Debug.WriteLine(sprintf "Using Zip to combine two arrays into one (1*10, 2*11, 3*12):") for number in result do Debug.WriteLine(sprintf "%d" number)Output:
Using Zip to combine two arrays into one (1*10, 2*11, 3*12): 10 22 36