以下方法无法编译.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;
}
Run Code Online (Sandbox Code Playgroud)
获得这种行为的最佳方法是什么?(请不要提供有关线程安全词典的建议,这个问题一般是为了解决out参数问题).