Reverse List Items Using VB.NET

In this article I explained, how to reverse list items in VB.NET.
  • 2446

Reverse

The Reverse method reverses the items of a List. The following code snippet creates and reverses a List.

Imports System.Text

Imports System.IO

Imports System.Collections.Generic

Module Module1

    Sub Main()

        Dim DepartmentList As New List(Of String)()

        DepartmentList.Add("Service")

        DepartmentList.Add("Finance")

        DepartmentList.Add("Maintenance")

        DepartmentList.Add("Testing")

        DepartmentList.Add("HR")

        ' Read all data

        Console.WriteLine("Original Department List")

        For Each department In DepartmentList

            Console.WriteLine(department)

        Next

        DepartmentList.Reverse()

        Console.WriteLine()

        Console.WriteLine()

        Console.WriteLine("Reversed Department List is :")

        For Each department In DepartmentList

            Console.WriteLine(department)

        Next

        Console.ReadLine()

    End Sub

End Module

Output:

 ReversedList-in-vb.net.jpg

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.