Main Site Documentation

Alternative to dictionary objekt


#1

in the netMF i can’t the dictionary objekt
similarly the linq

1.) is both not in the netMF ? or only I’m too stupid :slight_smile:

I have ca 50 Elements (key/objekt)

2.) what is in your opinion the best way to handle

  • sqlite ?
  • Arraylist ?
  • xml

I need help / an idea mayby a snippet

thankx


#2

NETMF does not support generics, therefore no Dictionary(Of TKey, TValue). Similarly LINQ relies on generics though I guess some approximation of it without generics could be implemented.

You could use the HashTable to store your key/value pairs. Do you require persistence or do the values only need to be in memory?


#3

Or you can implement your own:

http://www.tinyclr.com/codeshare/entry/117


#4

@ taylorza - i only need them while the program is running
but i have a lot of accesses


#5

You can use a HashTable, which is a crude Dictionary.

**** Oooops. Already suggested.


#6

Though I would wage a guess that was done before NETMF had it’s own Hashtable implementation? It would seen better to leverage tested code ESP. Since that particular implementation is using sequential scans to perform the key lookups.


#7

In that case Hashtable is the way to go.


#8

@ taylorza - I would personally use a hashtable :wink: Just wanted to show an alternative.


#9

@ Architect - the codeshare implementaion uses a “for” loop to find the right key. Because of that i thought asking the community

@ all has anyone a code snippet using the hashtable

thanx to all


#10

@ VB-Daniel - I would check Codeshare. There can be some real projects that use Hashtables

http://www.tinyclr.com/codeshare/search?q=Hashtable


#11

Here is my best estimate for VB.NET


Import System.Collections
...
Dim ht as New Hashtable()

' Add Items to the Hashtable
ht.Add("key1", "Value 1")
ht.Add("key2", "Value 2")
ht.Add("key3", "Value 3")
ht.Add("key4", "Value 4")

' Get an item from the Hashtable

Dim item as String = CType(ht("key1"), String)

' Check if item exists

If ht.Contains("key1") Then ...


#12

It is always a joy to see the commitment of the community

thanx a lot