Skip to content

M_CodeJam_Collections_EnumerableExtensions_UnionBy__2_1

Andrew Koryavchenko edited this page Jun 17, 2018 · 8 revisions

EnumerableExtensions.UnionBy(TSource, TKey) Method (IEnumerable(TSource), IEnumerable(TSource), Func(TSource, TKey), IEqualityComparer(TKey))

Produces the set union of two sequences by using the specified key and IEqualityComparer(T) to compare values.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static IEnumerable<TSource> UnionBy<TSource, TKey>(
	this IEnumerable<TSource> first,
	IEnumerable<TSource> second,
	Func<TSource, TKey> keySelector,
	IEqualityComparer<TKey> comparer
)

VB

<ExtensionAttribute>
Public Shared Function UnionBy(Of TSource, TKey) ( 
	first As IEnumerable(Of TSource),
	second As IEnumerable(Of TSource),
	keySelector As Func(Of TSource, TKey),
	comparer As IEqualityComparer(Of TKey)
) As IEnumerable(Of TSource)

F#

[<ExtensionAttribute>]
static member UnionBy : 
        first : IEnumerable<'TSource> * 
        second : IEnumerable<'TSource> * 
        keySelector : Func<'TSource, 'TKey> * 
        comparer : IEqualityComparer<'TKey> -> IEnumerable<'TSource> 

Parameters

 

first
Type: System.Collections.Generic.IEnumerable(TSource)
An IEnumerable(T) whose distinct elements form the first set for the union.
second
Type: System.Collections.Generic.IEnumerable(TSource)
An IEnumerable(T) whose distinct elements form the second set for the union.
keySelector
Type: System.Func(TSource, TKey)
A function to extract the key for each element.
comparer
Type: System.Collections.Generic.IEqualityComparer(TKey)
An IEqualityComparer(T) to compare values.

Type Parameters

 

TSource
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.UnionBy2(System.Collections.Generic.IEnumerable{0},System.Collections.Generic.IEnumerable{0},System.Func{0,1},System.Collections.Generic.IEqualityComparer{1})"]
TKey
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.UnionBy2(System.Collections.Generic.IEnumerable{0},System.Collections.Generic.IEnumerable{0},System.Func{0,1},System.Collections.Generic.IEqualityComparer{1})"]

Return Value

Type: IEnumerable(TSource)
An IEnumerable(T) that contains the elements from both input sequences, excluding duplicates.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(TSource). 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).

See Also

Reference

EnumerableExtensions Class
UnionBy Overload
CodeJam.Collections Namespace

Clone this wiki locally