VB.net Program to Demonstrate the Lastindexof() Method of Array Class

You are currently viewing VB.net Program to Demonstrate the Lastindexof() Method of Array Class

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

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

Imports System

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

        'Search the specified item in the array and return 
        'the index of the last occurrence of an item.
        index = Array.LastIndexOf(arr, 20)

        Console.WriteLine("Index of last occurrence of item {0} is: {1}", 20, index)
        Console.WriteLine()
    End Sub
End Module
Index of last occurrence of item 20 is: 3
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply