MoreEnumerableOrderedMergeT, TKey, TResult(IEnumerableT, IEnumerableT, FuncT, TKey, FuncT, TResult, FuncT, TResult, FuncT, T, TResult, IComparerTKey) Method

Merges two ordered sequences into one. Additional parameters specify the element key by which the sequences are ordered, the result when element is found in first sequence but not in the second, the result when element is found in second sequence but not in the first, the result when elements are found in both sequences and a method for comparing keys.

Definition

Namespace: MoreLinq
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
C#
public static IEnumerable<TResult> OrderedMerge<T, TKey, TResult>(
	this IEnumerable<T> first,
	IEnumerable<T> second,
	Func<T, TKey> keySelector,
	Func<T, TResult> firstSelector,
	Func<T, TResult> secondSelector,
	Func<T, T, TResult> bothSelector,
	IComparer<TKey>? comparer
)

Parameters

first  IEnumerableT
The first input sequence.
second  IEnumerableT
The second input sequence.
keySelector  FuncT, TKey
Function to extract a key given an element.
firstSelector  FuncT, TResult
Function to project the result element when only the first sequence yields a source element.
secondSelector  FuncT, TResult
Function to project the result element when only the second sequence yields a source element.
bothSelector  FuncT, T, TResult
Function to project the result element when only both sequences yield a source element whose keys are equal.
comparer  IComparerTKey
An IComparerT to compare keys.

Type Parameters

T
Type of elements in source sequences.
TKey
Type of keys used for merging.
TResult
Type of elements in the returned sequence.

Return Value

IEnumerableTResult
A sequence with projections from the two input sequences merged according to a key, as in a full outer join.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method uses deferred execution. The behavior is undefined if the sequences are unordered (by key) as inputs.

See Also