小编Jer*_*Lee的帖子

如何销毁 C# 数据,例如 Dictionary<string, List<Action<object>>>?

我定义了一个对象Dictionary<string, List<Action<object>>>来存储一些要调用的委托方法。如果我想毁掉这本词典。我需要List.Clear()先在字典中调用吗?还是直接打电话Dictionary.Clear就可以了?

这个:

foreach(KeyValuePair<string, List<Action<object>>> kvp in dict)
{
   kvp.Value.Clear();
}

dict.Clear();
dict = null;
Run Code Online (Sandbox Code Playgroud)

或者这个:

dict.Clear();
dict = null;
Run Code Online (Sandbox Code Playgroud)

c# delegates dictionary

1
推荐指数
1
解决办法
3552
查看次数

标签 统计

c# ×1

delegates ×1

dictionary ×1