csharp-dictionary 发表于 2020-07-14 更新于 2020-12-17 分类于 Language 阅读次数: 本文字数: 442 阅读时长 ≈ 1 分钟 初始化,遍历Dictionary<int, string> dict = new Dictionary<int, string>() { {1,"One"}, {2, "Two"}, {3,"Three"} };foreach (KeyValuePair<int, string> item in dict){ Console.WriteLine("Key: {0}, Value: {1}", item.Key, item.Value);}foreach (var it in nominalVals.Values){ sData[pos] = *((int*)&it); pos += 1;} 更新如果是结构体的话不能直接使用 x[‘x’] = xx 的方式更新,好奇怪。