Readonly Dictionary

Hello,

is there a way to create a Computed Property for an Readonly Dictionary (i tried…but it returns a full functional Dictionary)? Is there a way for creating something like that?

Greetings

you can write a wrapper class with only getters.

Please tell my something about it, Christian :wink:

you make a new class called ReadonlyDictionary, add there all the methods you want and call inside the methods the dictionary which you keep in a private property.

OK, but later on i wanna load the content e.g. into a Listbox…

For Each a As Foo In Dictionary.Values ListBox1.AddRow(a.Text) Next

Subclass Dictionary
override the methods that act as setters
value ( key As Variant, Assigns _value As Variant )
so they do nothing

use the new readonly dictionary you created

[quote=149988:@Norman Palardy]Subclass Dictionary
override the methods that act as setters
value ( key As Variant, Assigns _value As Variant )
so they do nothing

use the new readonly dictionary you created[/quote]
Hmmm…should work, but i does not look “clean” :wink:
Thank you Norman

The other option you have is to write your own class that wraps a dictionary
But the result ends up being much the same