HELP on BinarySearch or IndexOf fro arrays ???

  • Thread starter Thread starter serge calderara
  • Start date Start date
S

serge calderara

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
 
serge calderara said:
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.
 
Back
Top