Searches sorted Array for a specific element, using the IComparable(Of T) generic interface
Imports System
Imports System.Collections.Generic
Public Class Example
Public Shared Sub Main()
Dim numbers() As String = {"Ten","Two","One","Three","Four","Nine" }
For Each num As String In numbers
Console.WriteLine(num)
Next
Array.Sort(numbers)
For Each num As String In numbers
Console.WriteLine(num)
Next
Dim index As Integer = Array.BinarySearch(numbers, "Four")
Console.WriteLine(index)
index = Array.BinarySearch(numbers, "One")
Console.WriteLine(index)
End Sub
End Class
Related examples in the same category