public class DictWithDefault<TKey, TValue>
{
private readonly TValue defaultValue;
private readonly Dictionary<TKey, TValue> values = new Dictionary<TKey, TValue>(60);
public DictWithDefault(TValue defaultValue = default)
{
this.defaultValue = defaultValue;
}
public TValue this[TKey key]
{
get => this.values.TryGetValue(key, out var val) ? val : this.defaultValue;
set => this.values[key] = value;