Blog

Sorting and reversing an array in VB.NET

Aug 29, 2011 Blogs | Visual Basic .NET
Here, we will see how to use sorting and reversing an array.
Introduction

An  array is a group of contiguous or related data items that the share a conman name.

For example

This program defines the sorting and reversing an array.

Module Module1

    Sub Main()

        Dim x As Integer() = {30, 10, 80, 90, 20}

        Console.WriteLine("array before sorting")

        For Each i As Integer In x

            Console.Write("" & i)

        Next

        Console.WriteLine()

        Array.Sort(x)

        Array.Reverse(x)

        Console.WriteLine("Array after sorting and Reversing")

        For Each i As Integer In x

            Console.WriteLine(" " & i)

        Next

        Console.WriteLine()

    End Sub

End Module

Output of program:


console1.gif
Darwin Chaudhary

Darwin Chaudhary is working as a Software Tester.

  • 481rank
  • 82K readers
COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs