以下方法无法编译。Visual Studio 警告“不得在匿名方法中使用 out 参数”。该WithReaderLock(Proc action)
方法采用delegate void Proc()
.
public Boolean TryGetValue(TKey key, out TValue value)
{
Boolean got = false;
WithReaderLock(delegate
{
got = dictionary.TryGetValue(key, out value);
});
return got;
}
获得这种行为的最佳方法是什么?(请不要提供关于线程安全字典的建议,这个问题通常是为了解决 out 参数问题)。