M
Mario
Hi there,
I'm writing a piece of code with VS.Net 2003, Framework 1.1.
And I can't make BinarySearch to work right. Look at this sample:
Dim sexy() As String = {"-", "a", "b", "ba", "A", "Aa", "Ab", _
"Aba", "B", "Ba", "Bb", "Bba", "BA", "BAa", "BAb", "BAba"}
Dim index As Integer
index = Array.BinarySearch(sexy, "BAba") ' index = -11 ?? BUG!!
Debug.WriteLine(index.ToString) ' How no match???
index = Array.BinarySearch(sexy, "a") ' index = 1
Debug.WriteLine(index.ToString) ' this one works fine
' so, wtf I'm doing wrong?
Please help me if you can, because I'm bugged; and I dont want to go
with a silly For Each, If Then, snoopy loopy. Yea, I know I can also use
the Array.IndexOf, but expert writter Francesco Balena says it's slower
then BinarySearch on large arrays, that is my case.
Thank you very much!
Kind regards,
Mario
I'm writing a piece of code with VS.Net 2003, Framework 1.1.
And I can't make BinarySearch to work right. Look at this sample:
Dim sexy() As String = {"-", "a", "b", "ba", "A", "Aa", "Ab", _
"Aba", "B", "Ba", "Bb", "Bba", "BA", "BAa", "BAb", "BAba"}
Dim index As Integer
index = Array.BinarySearch(sexy, "BAba") ' index = -11 ?? BUG!!
Debug.WriteLine(index.ToString) ' How no match???
index = Array.BinarySearch(sexy, "a") ' index = 1
Debug.WriteLine(index.ToString) ' this one works fine
' so, wtf I'm doing wrong?
Please help me if you can, because I'm bugged; and I dont want to go
with a silly For Each, If Then, snoopy loopy. Yea, I know I can also use
the Array.IndexOf, but expert writter Francesco Balena says it's slower
then BinarySearch on large arrays, that is my case.
Thank you very much!
Kind regards,
Mario