473,322 Members | 1,307 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,322 software developers and data experts.

Whats the point of SortedList.IndexOfKey

So you pass in the Key and it returns the array index of the key. but you
cant do array index lookups. the indexer of the sortedlist does a binary
search based on the key. So whats the pointof this method? is there a way
to return a array item based on the index?
Feb 22 '06 #1
4 4344
Hi John,
the SortedList type has a GetByIndex method which allows you to enter the
ordinal position of an item in the list and retrieve the value stored at that
position.

Mark Dawson
http://www.markdawson.org
"john conwell" wrote:
So you pass in the Key and it returns the array index of the key. but you
cant do array index lookups. the indexer of the sortedlist does a binary
search based on the key. So whats the pointof this method? is there a way
to return a array item based on the index?

Feb 22 '06 #2
Sorry, i should have been more specific. I'm talking about the 2.0 Generic
SortedList. The 1.1 SortedList does have a GetByIndex. the 2.0 Generic
SortedList does not.

"Mark R. Dawson" wrote:
Hi John,
the SortedList type has a GetByIndex method which allows you to enter the
ordinal position of an item in the list and retrieve the value stored at that
position.

Mark Dawson
http://www.markdawson.org
"john conwell" wrote:
So you pass in the Key and it returns the array index of the key. but you
cant do array index lookups. the indexer of the sortedlist does a binary
search based on the key. So whats the pointof this method? is there a way
to return a array item based on the index?

Feb 22 '06 #3
In the SortedList you have the Values collection which can be referenced by
an ordinal position. I guess you could use your index value with that to
return the desired value.

Mark Dawson
http://www.markdawson.org
"john conwell" wrote:
Sorry, i should have been more specific. I'm talking about the 2.0 Generic
SortedList. The 1.1 SortedList does have a GetByIndex. the 2.0 Generic
SortedList does not.

"Mark R. Dawson" wrote:
Hi John,
the SortedList type has a GetByIndex method which allows you to enter the
ordinal position of an item in the list and retrieve the value stored at that
position.

Mark Dawson
http://www.markdawson.org
"john conwell" wrote:
So you pass in the Key and it returns the array index of the key. but you
cant do array index lookups. the indexer of the sortedlist does a binary
search based on the key. So whats the pointof this method? is there a way
to return a array item based on the index?

Feb 23 '06 #4
John,

You have:
GetByIndex to ger value by index and GetKey to get key by index.
--
HTH
Stoitcho Goutsev (100)

"john conwell" <jo*********@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
So you pass in the Key and it returns the array index of the key. but you
cant do array index lookups. the indexer of the sortedlist does a binary
search based on the key. So whats the pointof this method? is there a
way
to return a array item based on the index?

Feb 23 '06 #5

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

Similar topics

1
by: gerrod | last post by:
Hi - Does anyone know a way to created a SortedList (in the System.Collections namespace) that will sort on VALUES instead of KEYS... ? The scenario is this - I have a SortedList containing...
2
by: Curious | last post by:
Hi, I am using SortedList, but I am having problems with indexing. SortedList x = new SortedList(); x.Add(0, "zero"); x.Add(1, "one"); x.Add(3, "three"); Console.WriteLine(x.ToString());
2
by: newscorrespondent | last post by:
I have a list declared: public System.Collections.Generic.SortedList<int, System.Collections.Generic.List<MTGTracer ActiveList = new SortedList<int,List<MTGTracer>>(); The key is an integer...
2
by: Prez | last post by:
I started writing .net code yesterday and I am grasping it well enough. I have a few questions about SortedLists. I am using managed C++ if that makes any difference. Of the examples I...
4
by: SHEBERT | last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox and a generic SortedList<that does not works as a datasource to the ComboBox. Why? If I use List and generic List<>,...
2
by: Bruce Arnold | last post by:
I have a program that works fine using Remove and Add to update a value. The program processes a log file from a router and counts the hits based on url. It bothers me to use Remove/Add when all...
1
by: raylopez99 | last post by:
I seem to get name collision between the Generic collection SortedList and C++.NET Framework collection SortedList. How to resolve? Here are the libraries that seem to clash:...
2
by: Bruce Wood | last post by:
SortedList<Tgeneric has most of the methods of the old SortedList class, but it's missing a few, and one in particular that puzzles me. Anyone know why it has no GetByIndex method? It has...
6
by: n3tx | last post by:
Hi! I have a problem with sortedlist, i guess i dont understand how it works. I have a method called GetPublishingPlaces that returns an IList<PublishingPlace> (ex. contains 11 rows) I want...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.