hello.I have a destructor and I want to remove one of my Dictionary variables(that has 2 variables).how can I do that?please help me
hello.I have a destructor and I want to remove one of my Dictionary variables(that has 2 variables).how can I do that?please help me
Umm....Dictionary(TKey, TValue).Remove Method (System.Collections.Generic)? If not, try being more specific with your question.
If you understand what you're doing, you're not learning anything.
It could be worth mentioning that when an object goes out of scope in .net, it doesn't necessarily mean the destructor will be called immediately. I don't use destructors very much in .net but having done a few tests it would appear the destructors are called just before the object is GC'ed.
The point is, you can't guarantee when your dictionary variable will be deleted if the code to remove it is in a destructor... == unreliable.
you should implement IDisposable, for the reason theoobe mentioned.
perhaps a stupid suggestion... but if your dict will really only hold 2 values, why not use two variables
I think he means the collection is composed of pairs which is obvious since it uses a key,value pair.