Прочитај на енглеском Уреди

Делите путем


Enumerable.ExceptBy Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

Produces the set difference of two sequences according to a specified key selector function.

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Produces the set difference of two sequences according to a specified key selector function.

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

Source:
Except.cs
Source:
Except.cs
Source:
Except.cs

Produces the set difference of two sequences according to a specified key selector function.

C#
public static System.Collections.Generic.IEnumerable<TSource> ExceptBy<TSource,TKey>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TKey> second, Func<TSource,TKey> keySelector);

Type Parameters

TSource

The type of the elements of the input sequence.

TKey

The type of key to identify elements by.

Parameters

first
IEnumerable<TSource>

An IEnumerable<T> whose keys that are not also in second will be returned.

second
IEnumerable<TKey>

An IEnumerable<T> whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

keySelector
Func<TSource,TKey>

A function to extract the key for each element.

Returns

IEnumerable<TSource>

A sequence that contains the set difference of the elements of two sequences.

See also

Applies to

.NET 10 и друге верзије
Производ Верзије
.NET 6, 7, 8, 9, 10

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Source:
Except.cs
Source:
Except.cs
Source:
Except.cs

Produces the set difference of two sequences according to a specified key selector function.

C#
public static System.Collections.Generic.IEnumerable<TSource> ExceptBy<TSource,TKey>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TKey> second, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer);

Type Parameters

TSource

The type of the elements of the input sequence.

TKey

The type of key to identify elements by.

Parameters

first
IEnumerable<TSource>

An IEnumerable<T> whose keys that are not also in second will be returned.

second
IEnumerable<TKey>

An IEnumerable<T> whose keys that also occur in the first sequence will cause those elements to be removed from the returned sequence.

keySelector
Func<TSource,TKey>

A function to extract the key for each element.

comparer
IEqualityComparer<TKey>

The IEqualityComparer<T> to compare values.

Returns

IEnumerable<TSource>

A sequence that contains the set difference of the elements of two sequences.

See also

Applies to

.NET 10 и друге верзије
Производ Верзије
.NET 6, 7, 8, 9, 10