C# defaultdict

Run Settings
LanguageC#
Language Version
Run Command
using System; using System.Collections.Generic; public class DefaultDictionary<TKey, TValue> : Dictionary<TKey, TValue> where TValue : new() { public new TValue this[TKey key] { get { TValue val; if (!TryGetValue(key, out val)) { val = new TValue(); Add(key, val); } return val; } set { base[key] = value; } } } class MainClass { static void Main() { var d = new DefaultDictionary<int, int>(); d[0]++; Console.WriteLine(d[0]); } }
Editor Settings
Theme
Key bindings
Full width
Lines