ADVERTISEMENT
ADVERTISEMENT

VB.Net program to demonstrate the Reverse() method of Array class

Here, we are going to demonstrate the Reverse() method of Array class in VB.Net.
Submitted by Nidhi, on January 20, 2021

The Reverse() method is used to reverse the specified array.

Syntax:

Sub Reverse(ByVal arr() as object)

Parameters:

  • Arr: It is the specified integer array to be reversed.

Return Value: It does not return any value.

Program/Source Code:

The source code to demonstrate the Reverse() method of the Array class is given below. The given program is compiled and executed successfully.

'VB.NET program to demonstrate the Reverse() 
'method of Array class.

Imports System

Module Module1
    Sub Main()
        Dim arr() As Integer = {10, 20, 30, 40, 50}

        Console.WriteLine("Original Array elements: ")
        For i = 0 To arr.Length - 1 Step 1
            Console.Write(arr(i) & " ")
        Next

        Array.Reverse(arr)

        Console.WriteLine(vbCrLf & "Reversed Array elements: ")
        For i = 0 To arr.Length - 1 Step 1
            Console.Write(arr(i) & " ")
        Next

        Console.WriteLine()
    End Sub
End Module

Output:

Original Array elements:
10 20 30 40 50
Reversed Array elements:
50 40 30 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 array arr with 5 elements. After that, we reverse the array using the Reverse() method and then we printed the reversed array on the console screen.

VB.Net Array Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.