我遇到了我今天不了解的事情。请考虑以下代码段:
public class EventStreamCollection<TKey, TValue>
{
private readonly ConcurrentDictionary<TKey, TValue> _dictionary = new ConcurrentDictionary<TKey, TValue>();
private readonly Func<TKey, TValue> _factory;
public EventStreamCollection(Func<TKey, TValue> factory)
{
_factory = factory;
}
public TValue this[TKey key] => _dictionary.GetOrAdd(key, _factory);
}
这是什么
public TValue this[TKey key] => _dictionary.GetOrAdd(key, _factory);
它没有我能看到的名字。如果是的话,我想这将属于财产?它是什么以及它是如何工作的?