473,388 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

HELP on BinarySearch or IndexOf fro arrays ???

Dear all,

I have an array List of object, in that list of object I
would liek to know if a particular object item of that
list as a predifined value and then if exist the update
that object. The following code illustare that list.

================================================== =====
Dim objScan As Integer = Me.m_intSiteID

-- update the edited item in the list of object
Dim ListIdx As Integer
ListIdx = m_objUserRef.SiteList.BinarySearch(objScan)
================================================== ======

Site list is a collection.ArrayList type and contains
Object of Site (define by myself)

By doing a binary search I was hoping to be able to
retrive that idex number of the object that contain that
value in the List but I get an execption in ICompare
interface .

Is there anything wrong ?

Thnaks for your help
regard
serge
Jul 21 '05 #1
1 1385
serge calderara <se*************@maillefer.net> wrote:
Dear all,

I have an array List of object, in that list of object I
would liek to know if a particular object item of that
list as a predifined value and then if exist the update
that object. The following code illustare that list.

================================================== =====
Dim objScan As Integer = Me.m_intSiteID

-- update the edited item in the list of object
Dim ListIdx As Integer
ListIdx = m_objUserRef.SiteList.BinarySearch(objScan)
================================================== ======

Site list is a collection.ArrayList type and contains
Object of Site (define by myself)

By doing a binary search I was hoping to be able to
retrive that idex number of the object that contain that
value in the List but I get an execption in ICompare
interface .

Is there anything wrong ?


Yes - you're trying to search for an integer, when your list is full of
Site instances. You can't compare an integer and a Site, so you get an
exception.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dotNetDave | last post by:
I have created my own comparer class using IComparer for use with ArrayList.BinarySearch. My class seems to work with BinarySearch, but the problem is that my ArrayList has three items in it and it...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: Zanzibar | last post by:
H In Delphi the Search method has Two return values. 1 Bool to indicate if it is found and 1 integer to return the possition If the bool was false, the index was the possition where the item...
15
by: Chuck Bowling | last post by:
I'm having problems doing an efficient keyword search on a text file likely to be smaller than 100k. I have a keyword list of about 200 strings and I need to search the file and mark all of the...
7
by: Satish | last post by:
Hi Friends I am little confused about the shadows keyword in VB.NET could anyone explain with an example about Shadows keyword Many thanks Satish
2
by: Yogi21 | last post by:
Hi I have a sorted array containing strings. I am iterating through the array and clearing the contents one by one using "array.BinarySearch" to find each element. So far so good. But the moment I...
8
by: Sueffel | last post by:
Okay, I can certinatly use a For..Next loop to find the specified info I need, but I'm thinking the BinarySearch will be faster, if I can get it working LOL Anyhew, got an array, may have 5 or...
1
by: serge calderara | last post by:
Dear all, I have an array List of object, in that list of object I would liek to know if a particular object item of that list as a predifined value and then if exist the update that object....
2
by: Timmy | last post by:
The bigger problem is with the Binary Search. The program crashes when it's excuted. and Visual Studio 2005 indicates stack over flow and shows a break at that function. Sequential search is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.