Alternative to dictionary objekt

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


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?

Or you can implement your own:

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

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

**** Oooops. Already suggested.

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.

In that case Hashtable is the way to go.

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

@ 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

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

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 ...

1 Like

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

thanx a lot