List(T).BinarySearch Method searches sorted List(Of T) using the default comparer
Imports System
Imports System.Collections.Generic
Public Class Example
Public Shared Sub Main()
Dim numbers As New List(Of String)
numbers.Add("Ten")
numbers.Add("Two")
numbers.Add("Three")
numbers.Add("Four")
For Each num As String In numbers
Console.WriteLine(num)
Next
numbers.Sort
For Each num As String In numbers
Console.WriteLine(num)
Next
Dim index As Integer = numbers.BinarySearch("Two")
If index < 0 Then
index = index Xor -1
numbers.Insert(index, "Two")
End If
index = numbers.BinarySearch("One")
If index < 0 Then
index = index Xor -1
numbers.Insert(index, "One")
End If
End Sub
End Class