Click or drag to resize

MoreEnumerableOrderedMergeTFirst, TSecond, TKey, TResult Method (IEnumerableTFirst, IEnumerableTSecond, FuncTFirst, TKey, FuncTSecond, TKey, FuncTFirst, TResult, FuncTSecond, TResult, FuncTFirst, TSecond, TResult)

Merges two heterogeneous sequences ordered by a common key type into a homogeneous 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 and the result when element is found in second sequence but not in the first, the result when elements are found in both sequences.

Namespace:  MoreLinq
Assembly:  MoreLinq (in MoreLinq.dll) Version: 2.8.0
Syntax
public static IEnumerable<TResult> OrderedMerge<TFirst, TSecond, TKey, TResult>(
	this IEnumerable<TFirst> first,
	IEnumerable<TSecond> second,
	Func<TFirst, TKey> firstKeySelector,
	Func<TSecond, TKey> secondKeySelector,
	Func<TFirst, TResult> firstSelector,
	Func<TSecond, TResult> secondSelector,
	Func<TFirst, TSecond, TResult> bothSelector
)

Parameters

first
Type: System.Collections.GenericIEnumerableTFirst
The first input sequence.
second
Type: System.Collections.GenericIEnumerableTSecond
The second input sequence.
firstKeySelector
Type: SystemFuncTFirst, TKey
Function to extract a key given an element from the first sequence.
secondKeySelector
Type: SystemFuncTSecond, TKey
Function to extract a key given an element from the second sequence.
firstSelector
Type: SystemFuncTFirst, TResult
Function to project the result element when only the first sequence yields a source element.
secondSelector
Type: SystemFuncTSecond, TResult
Function to project the result element when only the second sequence yields a source element.
bothSelector
Type: SystemFuncTFirst, TSecond, TResult
Function to project the result element when only both sequences yield a source element whose keys are equal.

Type Parameters

TFirst
Type of elements in the first sequence.
TSecond
Type of elements in the second sequence.
TKey
Type of keys used for merging.
TResult
Type of elements in the returned sequence.

Return Value

Type: 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 IEnumerableTFirst. 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