473,320 Members | 2,080 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,320 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 1384
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.