如何重置字典 [英] How to reset a Dictionary
本文介绍了如何重置字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我宣布这样的字典。
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.
我喜欢这个网站,
谢谢你所有。
推荐答案
你可以使用清除方法,它将删除所有的键和值,然后可以重新使用它,而无需创建新的实例:
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();
这篇关于如何重置字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文