Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# Linq Zip Method
Merge sequences using predicate with Zip method.
Here are our arrays to be merged.
int[] intArray = { 10, 20, 30, 40 };
string[] stringArray = { "Jack", "Tim", "Henry", "Tom" };
Now let’s use the Zip method to merge both the arrays.
intArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two)
The following is our code.
Example
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] intArray = { 10, 20, 30, 40 };
string[] stringArray = { "Jack", "Tim", "Henry", "Tom" };
var mergedSeq = intArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two);
foreach (var ele in mergedSeq)
Console.WriteLine(ele);
}
}
Output
10 Jack 20 Tim 30 Henry 40 Tom
Advertisements
