×

VB.Net Programs

VB.Net program to demonstrate the LINQ Query to arrange array elements in descending order

By Nidhi Last Updated : November 11, 2024

VB.Net – LINQ Query to arrange array elements in descending order

In this program, we will create a LINQ query to arrange array elements in descending order and print them on the console screen.

Program/Source Code:

The source code to demonstrate the LINQ Query to arrange array elements in descending order is given below. The given program is compiled and executed successfully.

VB.Net code to implement LINQ Query to arrange array elements in descending order

'VB.NET program to demonstrate the Linq Query to 
'arrange array elements in descending order.

Imports System
Imports System.IO
Imports System.Linq

Module Module1
    Sub Main()
        Dim intVals() As Integer = {50, 20, 40, 35, 10, 27, 60}

        Dim result = From val In intVals Order By val Descending

        Console.WriteLine("Result: ")
        For Each val As Integer In result
            Console.Write(val & " ")
        Next
        Console.WriteLine()
    End Sub
End Module

Output

Result:
60 50 40 35 27 20 10
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.

In the Main() function, we created an integer array that contains 7 elements. Here, we executed the LinQ query and arrange array elements into descending order and print them on the console screen.

VB.Net LINQ Query Programs »


Comments and Discussions!

Load comments ↻





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