If I declared a dictionary like this:
private static Dictionary<string, object> aDict = new Dictionary<string, object>();
And now I want to use it at another place. How do I reset it?
aDict = new Dictionary<string, object>(); // like this? aDict = null; // or like this?
or other reset styles?
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();
1.4m articles
1.4m replys
5 comments
57.0k users