By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,064 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,064 IT Pros & Developers. It's quick & easy.

.Net equivalent of Scripting.Dictionary

P: n/a
Could someone suggest a good native .Net collection object that provides
similar functionality to the COM Scripting.Dictionary object?

Specifically I need to be able to add items with an associated key, retrieve
them by key or by index within the collection, and determine whether an item
exists in the collection by querying with its key.

The HashTable was looking good as it does virtually all of these things, but
it doesn't seem to be possible to retrieve its items by index, which is
something I need to be able to do.

Any suggestions?

--

(O)enone
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a


Oenone wrote:
Could someone suggest a good native .Net collection object that provides
similar functionality to the COM Scripting.Dictionary object?

Specifically I need to be able to add items with an associated key, retrieve
them by key or by index within the collection, and determine whether an item
exists in the collection by querying with its key.

The HashTable was looking good as it does virtually all of these things, but
it doesn't seem to be possible to retrieve its items by index, which is
something I need to be able to do.


I don't remember Dictionary being able to recover items by Index, but
anyway.

Have you looked at SortedList?

--
Larry Lard
Replies to group please

Nov 21 '05 #2

P: n/a
I would derive from dictionarybase and encapsulate an arraylist inside the
class. Sure, it would be more work, but in my experience these things are
pretty fast anyway.

"Oenone" <oe****@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Could someone suggest a good native .Net collection object that provides
similar functionality to the COM Scripting.Dictionary object?

Specifically I need to be able to add items with an associated key,
retrieve them by key or by index within the collection, and determine
whether an item exists in the collection by querying with its key.

The HashTable was looking good as it does virtually all of these things,
but it doesn't seem to be possible to retrieve its items by index, which
is something I need to be able to do.

Any suggestions?

--

(O)enone

Nov 21 '05 #3

P: n/a
Jon
Why not just use Scripting.Dictionary? ;)

Jon

"Oenone" <oe****@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Could someone suggest a good native .Net collection object that provides
similar functionality to the COM Scripting.Dictionary object?

Specifically I need to be able to add items with an associated key,
retrieve them by key or by index within the collection, and determine
whether an item exists in the collection by querying with its key.

The HashTable was looking good as it does virtually all of these things,
but it doesn't seem to be possible to retrieve its items by index, which
is something I need to be able to do.

Any suggestions?

--

(O)enone

Nov 21 '05 #4

P: n/a
Would you have to create COM wrappers for all the classes you intended to
put into the dictionary?

--
Jonathan Allen
"Jon" <Em***********@SomewhereOrOther.com> wrote in message
news:Om****************@TK2MSFTNGP12.phx.gbl...
Why not just use Scripting.Dictionary? ;)

Jon

"Oenone" <oe****@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Could someone suggest a good native .Net collection object that provides
similar functionality to the COM Scripting.Dictionary object?

Specifically I need to be able to add items with an associated key,
retrieve them by key or by index within the collection, and determine
whether an item exists in the collection by querying with its key.

The HashTable was looking good as it does virtually all of these things,
but it doesn't seem to be possible to retrieve its items by index, which
is something I need to be able to do.

Any suggestions?

--

(O)enone


Nov 21 '05 #5

P: n/a
Jon
Something like

'Reference added to scrrun.dll via Add Reference

Dim dict As New Scripting.Dictionary

Dim frm As New Form1

'Add data

dict.Add("1", CObj(frm))

'Retrieve data

Dim a As Form1

a = CType(dict.Item("1"), Form1)

a.ShowDialog()

'Key Exists?

Dim b As Boolean

b = dict.Exists("1")

MsgBox(b)

Jon

"Jonathan Allen" <x@x.x> wrote in message
news:#R**************@TK2MSFTNGP14.phx.gbl...
Would you have to create COM wrappers for all the classes you intended to
put into the dictionary?

--
Jonathan Allen
"Jon" <Em***********@SomewhereOrOther.com> wrote in message
news:Om****************@TK2MSFTNGP12.phx.gbl...
Why not just use Scripting.Dictionary? ;)

Jon

"Oenone" <oe****@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Could someone suggest a good native .Net collection object that provides similar functionality to the COM Scripting.Dictionary object?

Specifically I need to be able to add items with an associated key,
retrieve them by key or by index within the collection, and determine
whether an item exists in the collection by querying with its key.

The HashTable was looking good as it does virtually all of these things, but it doesn't seem to be possible to retrieve its items by index, which is something I need to be able to do.

Any suggestions?

--

(O)enone



Nov 21 '05 #6

P: n/a
Thanks for all the suggestions.

I eventually plumped for the
System.Collections.Specialized.StringDictionary. Accessing the objects by
index isn't quite as easy as it might be (I have to use the Keys.CopyTo()
method to copy all the keys to an array, and then can access the keys by
index) but it pretty much does what I need.

--

(O)enone
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.