It comes in handy of course that you can dynamically adjust the size of a List or Dictionary.
But this time I want to use a Dictionary with sizes from 1 to 8.
When I have e.g. size 3, it will stay that way.
On the net I found a solution to use a wrapper class around a Dictionary, which could do the job.
Should I resort to an array instead, or are there still other options?

Recommended Answers

All 4 Replies

Why exactly do you need this? Unless you're writing a library (in which case a wrapper is the appropriate solution), it's more a matter of careful coding and checking invariants where necessary.

I would like to simulate some digital gates like NAND-gate, OR-gate etc.
For the input ports I thought a Dictionary might be handy. With as key portnr and as value a signal enumeration, indicating the signal level. I know that for optimalisation reasons a collection is bigger than it needs to be, but for sizes of 1 to 8 input ports that is of no importance. Hence my question. Please correct me if you see other solutions.

Honestly, I wouldn't worry about it unless you're under some harsh memory constraints.

Thanks. I come from a past where every byte counted. I have to debrief on that I guess. :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.