Enumerable.Zip Yöntem

Tanım

Aşırı Yüklemeler

Zip<TFirst,TSecond,TResult>(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst,TSecond,TResult>)

Belirtilen bir işlevi, sonuçların bir dizisini oluşturan iki dizinin karşılık gelen öğelerine uygular.

Zip<TFirst,TSecond,TThird>(IEnumerable<TFirst>, IEnumerable<TSecond>, IEnumerable<TThird>)

Belirtilen üç dizideki öğelerle bir tanımlama grubu dizisi oluşturur.

Zip<TFirst,TSecond>(IEnumerable<TFirst>, IEnumerable<TSecond>)

Belirtilen iki dizideki öğelerle bir tanımlama grubu dizisi oluşturur.

Zip<TFirst,TSecond,TResult>(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst,TSecond,TResult>)

Kaynak:
Zip.cs
Kaynak:
Zip.cs
Kaynak:
Zip.cs

Belirtilen bir işlevi, sonuçların bir dizisini oluşturan iki dizinin karşılık gelen öğelerine uygular.

public:
generic <typename TFirst, typename TSecond, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<TResult> ^ Zip(System::Collections::Generic::IEnumerable<TFirst> ^ first, System::Collections::Generic::IEnumerable<TSecond> ^ second, Func<TFirst, TSecond, TResult> ^ resultSelector);
public static System.Collections.Generic.IEnumerable<TResult> Zip<TFirst,TSecond,TResult> (this System.Collections.Generic.IEnumerable<TFirst> first, System.Collections.Generic.IEnumerable<TSecond> second, Func<TFirst,TSecond,TResult> resultSelector);
static member Zip : seq<'First> * seq<'Second> * Func<'First, 'Second, 'Result> -> seq<'Result>
<Extension()>
Public Function Zip(Of TFirst, TSecond, TResult) (first As IEnumerable(Of TFirst), second As IEnumerable(Of TSecond), resultSelector As Func(Of TFirst, TSecond, TResult)) As IEnumerable(Of TResult)

Tür Parametreleri

TFirst

İlk giriş dizisinin öğelerinin türü.

TSecond

İkinci giriş dizisinin öğelerinin türü.

TResult

Sonuç dizisi öğelerinin türü.

Parametreler

first
IEnumerable<TFirst>

Birleştirilecek ilk sıra.

second
IEnumerable<TSecond>

Birleştirilecek ikinci sıra.

resultSelector
Func<TFirst,TSecond,TResult>

İki dizideki öğelerin nasıl birleştirildiğini belirten bir işlev.

Döndürülenler

IEnumerable<TResult>

IEnumerable<T> İki giriş dizisinin birleştirilmiş öğelerini içeren bir.

Özel durumlar

first veya second şeklindedir null.

Örnekler

Aşağıdaki kod örneği, iki diziyi birleştirmek için yönteminin Zip nasıl kullanılacağını gösterir.

int[] numbers = { 1, 2, 3, 4 };
string[] words = { "one", "two", "three" };

var numbersAndWords = numbers.Zip(words, (first, second) => first + " " + second);

foreach (var item in numbersAndWords)
    Console.WriteLine(item);

// This code produces the following output:

// 1 one
// 2 two
// 3 three
Dim numbers() As Integer = {1, 2, 3, 4}
Dim words() As String = {"one", "two", "three"}
Dim numbersAndWords = numbers.Zip(words, Function(first, second) first & " " & second)

For Each item In numbersAndWords
    Console.WriteLine(item)
Next

' This code produces the following output:

' 1 one
' 2 two
' 3 three

Açıklamalar

Bu yöntem ertelenmiş yürütme kullanılarak uygulanır. Anında dönüş değeri, eylemi gerçekleştirmek için gereken tüm bilgileri depolayan bir nesnedir. Bu yöntemle temsil edilen sorgu, doğrudan yöntemini çağırarak GetEnumerator veya C# içinde veya For Each Visual Basic'te kullanarak foreach nesne numaralandırılana kadar yürütülür.

yöntemi, ilk dizinin her öğesini ikinci dizide aynı dizine sahip bir öğeyle birleştirir. Diziler aynı sayıda öğeye sahip değilse, yöntem dizilerden birinin sonuna ulaşana kadar dizileri birleştirir. Örneğin, bir dizide üç öğe ve diğerinde dört öğe varsa, sonuç dizisinde yalnızca üç öğe olur.

Ayrıca bkz.

Şunlara uygulanır

Zip<TFirst,TSecond,TThird>(IEnumerable<TFirst>, IEnumerable<TSecond>, IEnumerable<TThird>)

Kaynak:
Zip.cs
Kaynak:
Zip.cs
Kaynak:
Zip.cs

Belirtilen üç dizideki öğelerle bir tanımlama grubu dizisi oluşturur.

public:
generic <typename TFirst, typename TSecond, typename TThird>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<ValueTuple<TFirst, TSecond, TThird>> ^ Zip(System::Collections::Generic::IEnumerable<TFirst> ^ first, System::Collections::Generic::IEnumerable<TSecond> ^ second, System::Collections::Generic::IEnumerable<TThird> ^ third);
public static System.Collections.Generic.IEnumerable<(TFirst First, TSecond Second, TThird Third)> Zip<TFirst,TSecond,TThird> (this System.Collections.Generic.IEnumerable<TFirst> first, System.Collections.Generic.IEnumerable<TSecond> second, System.Collections.Generic.IEnumerable<TThird> third);
static member Zip : seq<'First> * seq<'Second> * seq<'hird> -> seq<ValueTuple<'First, 'Second, 'hird>>
<Extension()>
Public Function Zip(Of TFirst, TSecond, TThird) (first As IEnumerable(Of TFirst), second As IEnumerable(Of TSecond), third As IEnumerable(Of TThird)) As IEnumerable(Of ValueTuple(Of TFirst, TSecond, TThird))

Tür Parametreleri

TFirst

İlk giriş dizisinin öğelerinin türü.

TSecond

İkinci giriş dizisinin öğelerinin türü.

TThird

Üçüncü giriş dizisinin öğelerinin türü.

Parametreler

first
IEnumerable<TFirst>

Birleştirilecek ilk sıra.

second
IEnumerable<TSecond>

Birleştirilecek ikinci sıra.

third
IEnumerable<TThird>

Birleştirilecek üçüncü sıra.

Döndürülenler

IEnumerable<ValueTuple<TFirst,TSecond,TThird>>

Bu sırada birinci, ikinci ve üçüncü sıralardan alınan öğelerle bir tanımlama grubu dizisi.

Ayrıca bkz.

Şunlara uygulanır

Zip<TFirst,TSecond>(IEnumerable<TFirst>, IEnumerable<TSecond>)

Kaynak:
Zip.cs
Kaynak:
Zip.cs
Kaynak:
Zip.cs

Belirtilen iki dizideki öğelerle bir tanımlama grubu dizisi oluşturur.

public:
generic <typename TFirst, typename TSecond>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<ValueTuple<TFirst, TSecond>> ^ Zip(System::Collections::Generic::IEnumerable<TFirst> ^ first, System::Collections::Generic::IEnumerable<TSecond> ^ second);
public static System.Collections.Generic.IEnumerable<(TFirst First, TSecond Second)> Zip<TFirst,TSecond> (this System.Collections.Generic.IEnumerable<TFirst> first, System.Collections.Generic.IEnumerable<TSecond> second);
static member Zip : seq<'First> * seq<'Second> -> seq<ValueTuple<'First, 'Second>>
<Extension()>
Public Function Zip(Of TFirst, TSecond) (first As IEnumerable(Of TFirst), second As IEnumerable(Of TSecond)) As IEnumerable(Of ValueTuple(Of TFirst, TSecond))

Tür Parametreleri

TFirst

İlk giriş dizisinin öğelerinin türü.

TSecond

İkinci giriş dizisinin öğelerinin türü.

Parametreler

first
IEnumerable<TFirst>

Birleştirilecek ilk sıra.

second
IEnumerable<TSecond>

Birleştirilecek ikinci sıra.

Döndürülenler

IEnumerable<ValueTuple<TFirst,TSecond>>

Birinci ve ikinci dizilerden alınan öğelerle bu sırada bir tanımlama grubu dizisi.

Ayrıca bkz.

Şunlara uygulanır