Using the ZIP operator
The ZIP operator used to parse the elements at the same index position in each squence. When one sequence is completes reading its elements, the result is returned.
Now, we add the Default.aspx page and write the following code:
Now, double click on Display Record button and write the following code:-
Now run the application and click on Display Record button and get output.
Now, we add the Default.aspx page and write the following code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Now, double click on Display Record button and write the following code:-
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnDisplayRecord_Click(object sender, EventArgs e) { lbDetail.Items.Clear(); string[] Name = { "Santosh kumar singh", "Manorma arya", "Prem Kumar", "Pooja", "Narendra Modi", }; string[] Position = { "Dotnet Programmer", "Manger", "PSA", "Developer", "PM", }; int[] Year = { 4, 3, 25, 2, 6 }; var q = Name.Zip(Position, (a, b) => a + " is the " + b + " of the company"); var r = q.Zip(Year, (c, d) => c + " with " + d + " years of experience"); foreach (var data in r) { lbDetail.Items.Add(data); } } }
Now run the application and click on Display Record button and get output.