【发布时间】:2012-07-27 16:31:13
【问题描述】:
我正在使用 Visual Studio 2010 C++ Express,我想向我的 ConcurrentDictionary 添加一个项目:
我有这样的代码:
String^ key = gcnew String("key");
int value = 123;
myDictionary->AddOrUpdate(key,value,/*WHAT TO ADD HERE?*/);
AddOrUpdate 方法需要 3 个参数,不像普通的字典 2。
微软网站表示它需要这样的论点:
public:
TValue AddOrUpdate(
TKey key,
TValue addValue,
Func<TKey, TValue, TValue>^ updateValueFactory
)
在微软网站上,我还发现了 C# 代码:
cd.AddOrUpdate(1, 1, (key, oldValue) => oldValue + 1);
但它在 C++ 中不起作用。我必须把什么作为第三个参数?
【问题讨论】:
标签: visual-studio-2010 c++-cli concurrentdictionary