Using Join clause
We can use the join clause to combine two source of data based on specific requirement:-

Now, we add the Default.aspx page and write the following code:

  

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <center> 
    <div>
        <h1>Type Join in LINQ:-</h1>
        <asp:ListBox ID="lbDetail" runat="server" Height="300px" Width="500px"></asp:ListBox> <br /> <br />
        <asp:Button ID="btnDisplayRecord" runat="server" Text="Display Record" Font-Bold="true" OnClick="btnDisplayRecord_Click" />
    
    </div>
            </center>
    </form>
</body>
</html>




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)
    {

    }

    public class Student
    {
        public int Rollno;
        public string Name;
    }
    public class Record
    {
        public int Rollno;
        public string Branch;
    }

    protected void btnDisplayRecord_Click(object sender, EventArgs e)
    {
        lbDetail.Items.Clear();

        var students = new List<Student>()
        {
            new Student{Rollno=1001,Name="Santosh Kumar Singh"},
            new Student{Rollno=1002,Name="Nand Kishor"},
            new Student{Rollno=1003,Name="Manish Kumar"},
            new Student{Rollno=1004,Name="Ankish Kuamr"},
            new Student{Rollno=1005,Name="Tanish Kumar"},
            new Student{Rollno=1006,Name="Monorma Arya"},

        };

        var records = new List<Record>()
        {
            new Record {Rollno=1001,Branch="IT"},
            new Record {Rollno=1002,Branch="BCA"},
            new Record {Rollno=1003,Branch="ME"},
            new Record {Rollno=1004,Branch="MCA"},
            new Record {Rollno=1005,Branch="IT"},
            new Record {Rollno=1006,Branch="MCA"},
            new Record {Rollno=1007,Branch="ECE"},

        };

        var query = from s in students join r in records on s.Rollno equals r.Rollno select new { s.Name, r.Branch };

        foreach (var data in query)
        {
            lbDetail.Items.Add(data.Name.ToString() + " " + data.Branch.ToString());

        }        
    }
}



Now, we run application and click on Display Record button and output will display according to our expectation.