Dictionary 的使用

1. 定义字典变量,并初始化

  // 元素值字典
Dictionary<string, string> dic = new Dictionary<string, string>()
{
{ "名称",""},
{"描述1",""},
{"拆分2",""}
}

2.清空字典值,保留键

    Dictionary<string, string>.KeyCollection  keys = dic.Keys;
String[] s = keys.ToArray<string>();
foreach (string a in s)
{
dic[a] = "";
}

不能直接用foreach循环,直接改变dic值,因为foreach是只读的。

上一篇:JVM调优常用参数和注意点备忘录


下一篇:syncer.go