Skip to main content
.NET Framework Class Library
EnumerableJoinTOuter, TInner, TKey, TResult Method (IEnumerableTOuter, IEnumerableTInner, FuncTOuter, TKey, FuncTInner, TKey, FuncTOuter, TInner, TResult, IEqualityComparerTKey)

Correlates the elements of two sequences based on matching keys. A specified IEqualityComparerT is used to compare keys.

Namespace:   System.Linq
Assembly:  System.Core (in System.Core.dll)
<[%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_0%]> _
Public Shared Function Join(Of TOuter, TInner, TKey, TResult) ( _
	outer As [%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_1%](Of TOuter), _
	inner As [%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_2%](Of TInner), _
	outerKeySelector As [%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_3%](Of TOuter, TKey), _
	innerKeySelector As [%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_4%](Of TInner, TKey), _
	resultSelector As [%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_5%](Of TOuter, TInner, TResult), _
	comparer As [%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_6%](Of TKey) _
) As [%$TOPIC/bb549267_en-us_VS_110_2_0_0_0_7%](Of TResult)
public static [%$TOPIC/bb549267_en-us_VS_110_2_0_1_0_0%]<TResult> Join<TOuter, TInner, TKey, TResult>(
	this [%$TOPIC/bb549267_en-us_VS_110_2_0_1_0_1%]<TOuter> outer,
	[%$TOPIC/bb549267_en-us_VS_110_2_0_1_0_2%]<TInner> inner,
	[%$TOPIC/bb549267_en-us_VS_110_2_0_1_0_3%]<TOuter, TKey> outerKeySelector,
	[%$TOPIC/bb549267_en-us_VS_110_2_0_1_0_4%]<TInner, TKey> innerKeySelector,
	[%$TOPIC/bb549267_en-us_VS_110_2_0_1_0_5%]<TOuter, TInner, TResult> resultSelector,
	[%$TOPIC/bb549267_en-us_VS_110_2_0_1_0_6%]<TKey> comparer
generic<typename TOuter, typename TInner, typename TKey, typename TResult>
static [%$TOPIC/bb549267_en-us_VS_110_2_0_2_0_1%]<TResult>^ Join(
	[%$TOPIC/bb549267_en-us_VS_110_2_0_2_0_2%]<TOuter>^ outer, 
	[%$TOPIC/bb549267_en-us_VS_110_2_0_2_0_3%]<TInner>^ inner, 
	[%$TOPIC/bb549267_en-us_VS_110_2_0_2_0_4%]<TOuter, TKey>^ outerKeySelector, 
	[%$TOPIC/bb549267_en-us_VS_110_2_0_2_0_5%]<TInner, TKey>^ innerKeySelector, 
	[%$TOPIC/bb549267_en-us_VS_110_2_0_2_0_6%]<TOuter, TInner, TResult>^ resultSelector, 
	[%$TOPIC/bb549267_en-us_VS_110_2_0_2_0_7%]<TKey>^ comparer
static member Join : 
        outer:[%$TOPIC/bb549267_en-us_VS_110_2_0_3_0_0%]<'TOuter> * 
        inner:[%$TOPIC/bb549267_en-us_VS_110_2_0_3_0_1%]<'TInner> * 
        outerKeySelector:[%$TOPIC/bb549267_en-us_VS_110_2_0_3_0_2%]<'TOuter, 'TKey> * 
        innerKeySelector:[%$TOPIC/bb549267_en-us_VS_110_2_0_3_0_3%]<'TInner, 'TKey> * 
        resultSelector:[%$TOPIC/bb549267_en-us_VS_110_2_0_3_0_4%]<'TOuter, 'TInner, 'TResult> * 
        comparer:[%$TOPIC/bb549267_en-us_VS_110_2_0_3_0_5%]<'TKey> -> [%$TOPIC/bb549267_en-us_VS_110_2_0_3_0_6%]<'TResult> 
JScript does not support generic types or methods.

Type Parameters


The type of the elements of the first sequence.


The type of the elements of the second sequence.


The type of the keys returned by the key selector functions.


The type of the result elements.


Type: System.Collections.GenericIEnumerableTOuter

The first sequence to join.

Type: System.Collections.GenericIEnumerableTInner

The sequence to join to the first sequence.

Type: SystemFuncTOuter, TKey

A function to extract the join key from each element of the first sequence.

Type: SystemFuncTInner, TKey

A function to extract the join key from each element of the second sequence.

Type: SystemFuncTOuter, TInner, TResult

A function to create a result element from two matching elements.

Type: System.Collections.GenericIEqualityComparerTKey

An IEqualityComparerT to hash and compare keys.

Return Value

Type: System.Collections.GenericIEnumerableTResult
An IEnumerableT that has elements of type TResult that are obtained by performing an inner join on two sequences.

Usage Note

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

outer or inner or outerKeySelector or innerKeySelector or resultSelector is .


This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its GetEnumerator method directly or by using foreach in Visual C# or For Each in Visual Basic.

If comparer is , the default equality comparer, Default, is used to hash and compare keys.

A join refers to the operation of correlating the elements of two sources of information based on a common key. Join brings the two information sources and the keys by which they are matched together in one method call. This differs from the use of SelectMany, which requires more than one method call to perform the same operation.

Join preserves the order of the elements of outer, and for each of these elements, the order of the matching elements of inner.

In relational database terms, the Join method implements an inner equijoin. 'Inner' means that only elements that have a match in the other sequence are included in the results. An 'equijoin' is a join in which the keys are compared for equality. A left outer join operation has no dedicated standard query operator, but can be performed by using the GroupJoin method. See Join Operations.

Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8