Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save defunkt/211492 to your computer and use it in GitHub Desktop.
Save defunkt/211492 to your computer and use it in GitHub Desktop.

Revisions

  1. @khigia khigia created this gist Oct 16, 2009.
    5 changes: 5 additions & 0 deletions Dictionary lookup with default
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    public static V GetValueOrDefault<K, V>(this Dictionary<K, V> dic, K key, V defaultVal)
    {
    V ret;
    return dic.TryGetValue (key, out ret) ? ret : defaultVal;
    }