Skip to content

M_CodeJam_Collections_EnumerableExtensions_IntersectBy__2

andrewvk edited this page Jun 23, 2016 · 8 revisions

EnumerableExtensions.IntersectBy(TSource, TKey) Method (IEnumerable(TSource), IEnumerable(TSource), Func(TSource, TKey))

Produces the set intersection of two sequences by using the specified key to compare values.

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

Syntax

C#

public static IEnumerable<TSource> IntersectBy<TSource, TKey>(
	this IEnumerable<TSource> first,
	IEnumerable<TSource> second,
	Func<TSource, TKey> keySelector
)

VB

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

F#

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

Parameters

 

first
Type: System.Collections.Generic.IEnumerable(TSource)
An IEnumerable(T) whose distinct elements that also appear in second will be returned.
second
Type: System.Collections.Generic.IEnumerable(TSource)
An IEnumerable(T) whose distinct elements that also appear in the first sequence will be returned.
keySelector
Type: System.Func(TSource, TKey)
A function to extract the key for each element.

Type Parameters

 

TSource
TKey

Return Value

Type: IEnumerable(TSource)
A sequence that contains the elements that form the set intersection of two sequences.

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
IntersectBy Overload
CodeJam.Collections Namespace

Clone this wiki locally