如何从使用元组的字典中删除元素
How to remove element from Dictionary that uses Tuple
我在 winform 上使用 C# 4.5。我有一个字典,其中有一个名为 ParamList 的元组,它使用这个:
new Dictionary<Tuple<string, string>, string>();
我能够遍历 ParamList 以将元素放入我的 ComboBox 中。我想要做的是通过单击按钮事件向上或向下移动元素,或者通过单击不同的按钮完全删除一个元素。我不知道该怎么做。谢谢
使用元组删除
var dict = new Dictionary<Tuple<string, string>, string>();
dict.Add(new Tuple<string, string>("a", "b"), "c");
dict.Remove(new Tuple<string, string>("a", "b"));
System.Diagnostics.Debug.Assert(dict.Count == 0);
我在 winform 上使用 C# 4.5。我有一个字典,其中有一个名为 ParamList 的元组,它使用这个:
new Dictionary<Tuple<string, string>, string>();
我能够遍历 ParamList 以将元素放入我的 ComboBox 中。我想要做的是通过单击按钮事件向上或向下移动元素,或者通过单击不同的按钮完全删除一个元素。我不知道该怎么做。谢谢
使用元组删除
var dict = new Dictionary<Tuple<string, string>, string>();
dict.Add(new Tuple<string, string>("a", "b"), "c");
dict.Remove(new Tuple<string, string>("a", "b"));
System.Diagnostics.Debug.Assert(dict.Count == 0);