Searches for the first occurrence of the duplicated value in the last section of the Array : Array Search « Data Structure « VB.Net






Searches for the first occurrence of the duplicated value in the last section of the Array

 


Imports System
Imports Microsoft.VisualBasic

Public Class SamplesArray    
    Public Shared Sub Main()
        Dim myArray As Array = Array.CreateInstance(GetType(String), 12)
        myArray.SetValue("1", 0)
        myArray.SetValue("2", 1)
        myArray.SetValue("3", 2)
        myArray.SetValue("4", 3)
        myArray.SetValue("5", 4)
        myArray.SetValue("6", 5)
        myArray.SetValue("4", 6)
        myArray.SetValue("8", 7)
        myArray.SetValue("9", 8)
        myArray.SetValue("10", 9)
        myArray.SetValue("11", 10)
        myArray.SetValue("12", 11)

        PrintIndexAndValues(myArray)
        Dim myString As String = "4"
        
        Dim myIndex As Integer = Array.IndexOf(myArray, myString, 4)
        Console.WriteLine(myIndex)

    End Sub


    Public Shared Sub PrintIndexAndValues(myArray As Array)
        Dim i As Integer
        For i = myArray.GetLowerBound(0) To myArray.GetUpperBound(0)
            Console.WriteLine(myArray.GetValue(i))
        Next i
    End Sub
End Class

   
  








Related examples in the same category

1.Array: Binary Search, CopyArray: Binary Search, Copy
2.Array.Find<(Of <(T>)>),
3.Array.FindLast<(Of <(T>)>)
4.Array.FindAll<(Of <(T>)>)
5.Array.Exists<(Of <(T>)>)
6.Array.TrueForAll<(Of <(T>)>)
7.All three generic overloads of the Array.IndexOf method.
8.Searches an entire one-dimensional sorted Array for a specific element
9.Searches sorted Array for a specific element, using the IComparable(Of T) generic interface
10.Searches sorted Array for a value using the specified IComparer(Of T) generic interface.
11.Searches for an element that matches the conditions defined by the specified predicate
12.Searches for an element that matches the conditions
13.Searches for the object and returns the index of the first occurrence
14.Searches for the first occurrence of the duplicated value in a section of the Array
15.Array.IndexOf(T) searches for the object and returns the index of the first occurrence
16.Searches for the object and returns the index of the last occurrence
17.Searches for the last occurrence of the duplicated value in the first section of the Array.
18.Searches for the last occurrence of the duplicated value in a section of the Array.
19.Array.LastIndexOf(T) searches for the specified object and returns the index of the last occurrence
20.Determines whether an array contains elements
21.Array.FindLastIndex