Click here to Skip to main content
15,943,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Assumed we have an instance in the safe (managed by GC) code:
Dictionary<Guid, Dictionary<int, SomeClass>> dictionary;

Would it be "enough properly", please,
to call the dictionary.Clear() to rebuild (refill) it,
or it should be called for the nested (no more needed, allocated by new) items too ? :)

The count of the outer dictionary's entries averages 100,
the entries' count of the inner dictionaries can exceed 10000
and it can be rebuilt (refilled) by an user's mouse click at any time...

...should I dispose and reconstruct the objects explicitly too ?

Thank you !

/the value type corrected/edit
Updated 3-Aug-10 5:45am

1 solution

You should change this design IMHO. There are a couple of problems I can see here:

1. Nested generics. MS code analysis will show that as error depending on the settings you have.
2. You are using object as a value in the Dictionary. The defeats whole purpose of having a strongly typed collection.

If you are using .Net 3.0 or above, go for custom colelction or in case you are using .Net 2.0, write your own class with suitable properties in it.
Share this answer
Eugen Podsypalnikov 3-Aug-10 11:42am    
Sorry, I'm using a class type as the value, of course.
Thank you, I will try to find some custom collection :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900