<p>Currently I'm using</p>

<pre><code>var x = dict.ContainsKey(key) ? dict[key] : defaultValue
</code></pre>

<p>I'd like some way to have dictionary[key] return null for nonexistant keys, so I could write something like</p>

<pre><code>var x =  dict[key] ?? defaultValue;
</code></pre>

<p>this also winds up being part of linq queries etc. so I'd prefer one-line solutions. </p>

You can use a helper method:
```
```
public abstract class MyHelper {
    public static V GetValueOrDefault<K,V>( Dictionary<K,V> dic, K key ) {
        V ret;
        bool found = dic.TryGetValue( key, out ret );
        if ( found ) { return ret; }
        return default(V);
    }
}

var x = MyHelper.GetValueOrDefault( dic, key );
```
```