tags:

views:

119

answers:

4

Hello.

If I declared a dictionary like this.

private static Dictionary<string, object> aDict = new Dictionary<string, object>();

And i still want to use it at another place. How to reset it?

aDict = new Dictionary<string, object>(); // like this?

aDict = null; // Like this ?

or other reset styles? THANK YOU.


I love the site,

THANK YOU ALL.

+12  A: 

You can simply use the Clear method, it will remove all keys and values, then you can reuse it without having to create new instances:

aDict.Clear();
CMS
+6  A: 

Try this

aDict.Clear();
Anuraj
+4  A: 

aDict.Clear(); will work.

Alan
+1  A: 

aDict.Clear(); is the only way to go since you dont want to change the reference (keep the same object availalbe "at another place"!!!

manubaum