×

VB.Net Programs

VB.Net program to demonstrate the Join using LINQ query

By Nidhi Last Updated : November 11, 2024

VB.Net – Join using LINQ Query

In this program, we will use the LINQ query to join two string arrays and find the common elements. After that print common elements on the console screen.

Program/Source Code:

The source code to demonstrate the Join using the LINQ query is given below. The given program is compiled and executed successfully.

VB.Net code to demonstrate the example of Join using LINQ query

'VB.NET program to demonstrate the 
'Join using LINQ query.

Imports System
Imports System.IO
Imports System.Linq

Module Module1
    Sub Main()
        Dim students As String() = {"Amit", "Arun", "Anup", "Akash", "Akhilesh"}
        Dim employees As String() = {"Ram", "Arun", "Mohan", "Akash", "Vivek"}

        Dim common = From s In students
                     Join e In employees On s Equals e
                     Select s

        Console.WriteLine("Common Names:")
        For Each name In common
            Console.WriteLine(vbTab & name)
        Next
    End Sub
End Module

Output

Common Names:
        Arun
        Akash
Press any key to continue . . .

Explanation

In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program. Here, we created the two array of strings that are initialized with student and employee names.

VB.Net LINQ Query Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.