using System.Collections.Generic;
public static void Main()
var dictList = new Dictionary<string, List<int>>();
dictList.Add("example", 5);
dictList.Add("example", 10);
dictList.Add("example", 15);
Console.WriteLine(String.Join(", ", dictList["example"]));
dictList.Remove("example", 5);
dictList.Remove("example", 10);
Console.WriteLine(String.Join(", ", dictList["example"]));
dictList.Remove("example", 15);
Console.WriteLine(dictList.ContainsKey("example"));
public static class DictListExtensions
public static void Add<TKey, TValue, TCollection>(this Dictionary<TKey, TCollection> dict, TKey key, TValue value)
where TCollection : ICollection<TValue>, new()
if (!dict.TryGetValue(key, out list))
list = new TCollection();
public static bool Remove<TKey, TValue, TCollection>(this Dictionary<TKey, TCollection> dict, TKey key, TValue value)
where TCollection : ICollection<TValue>
if (!dict.TryGetValue(key, out list))
var ret = list.Remove(value);