![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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