
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# Program to merge sequences
Let’s add two sequences.
Integer Array.
int[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8 };
String Array.
string[] stringArray = { "Depp", "Cruise", "Pitt", "Clooney", "Sandler", "Affleck", "Tarantino" };
Now to merge both the above sequences, use the Zip method.
ntArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two);
Let us see the complete code.
Example
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { int[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8 }; string[] stringArray = { "Depp", "Cruise", "Pitt", "Clooney", "Sandler", "Affleck", "Tarantino" }; var mergedSeq = intArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two); foreach (var ele in mergedSeq) Console.WriteLine(ele); } }
Output
1 Depp 2 Cruise 3 Pitt 4 Clooney 5 Sandler 6 Affleck 7 Tarantino
- Related Articles
- Python program to merge to dictionaries.
- C++ Program to Find the Longest Subsequence Common to All Sequences in a Set of Sequences
- C++ program to find n valid bracket sequences
- Python program to merge two Dictionaries
- C# program to merge two Dictionaries
- C++ Program to Implement Merge Sort
- Java Program to Merge two lists
- Golang program to merge two slices
- Python Program to Merge two Tuples
- C# Program to return the difference between two sequences
- Program to merge strings alternately using Python
- C# Program to Merge Two Hashtable Collections
- Python Program for Merge Sort
- Program to merge two binary trees in C++
- Program to merge K-sorted lists in Python

Advertisements