title: Select Value from Dictionary if Key exists using LINQ
body: <p>I have a dictionary where I have a <code>List</code> as value. I want to select specific elements from the list that belongs to a specific key. I tried this so far:</p>
  
  <pre><code>Dictionary&lt;int, List&lt;bool&gt;&gt; dic = new Dictionary&lt;int, List&lt;bool&gt;&gt;();
  dic.Add(1, new List&lt;bool&gt; { true, true, false });
  var works = dic.Where(x =&gt; x.Key == 1).SingleOrDefault().Value.Where(x =&gt; x == true).ToList();
  var doesNotWork = dic.Where(x =&gt; x.Key == 2).SingleOrDefault().Value.Where(x =&gt; x == true).ToList();
  </code></pre>
  
  <p>The first LINQ works because there is a key equal to 1. Thus I get a <code>List&lt;bool&gt;</code> with two elements.
  The second LINQ does not work because Value is <code>null</code>. How can I rewrite that LINQ such that if there is no suitable key in the dictionary I get an empty <code>List&lt;bool&gt;</code>?</p>
  
  <p>I thought my approach would work because I thought the default element had an empty list instead of null as Value.</p>