Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

negative index?

0 views
Skip to first unread message

Ben Black

unread,
Mar 5, 2003, 7:29:31 PM3/5/03
to
I'm using a binary search of an ArrayList created using name.Add(element).
For some reason the binary search is returning a negative number as the
index of the element in the array when I run the following code:

output.Text=b_code.BinarySearch(list[0].ToString());

It would seem to me that b_code actually does contain the string list[0]
because a .Contains statement returns true. The index should be 1 and the
array contains about 675 elements. Instead, the binary search returns
"-607" Any idea why it might do that? Does using .Add in an ArrayList
create the array with negative indexes somehow? I'm just really confused as
to why it would return a negative index for something that it knows exists.
Any help would be appreciated.
~Ben

0 new messages