title: Enum array Contains String Dictionary Key C#
body: <p>I am using a Dictionary with key , value as of type string</p>
  <pre><code>       var dictionary = new Dictionary&lt;string, string&gt;();
          dictionary.Add(&quot;cat&quot;,null);
          dictionary.Add(&quot;dog&quot;, &quot;vals&quot;);
          dictionary.Add(&quot;Tiger&quot;, &quot;s&quot;);   
  </code></pre>
  <p>There is a custom enum class like this exists</p>
  <pre><code>public enum AnimalName
  {      
      Cat = 0,         
      Dog = 1,       
      Rabit = 2,      
      Tiger = 3,        
      Lion = 4
  }
   
  </code></pre>
  <p>There is a permitted list of values from this enum available</p>
  <pre><code>        AnimalName[] permitted_list   = {
                  AnimalName.Cat,
                  AnimalName.Dog,
                  AnimalName.Rabit
              };
          
  </code></pre>
  <p>How can we check the dictionary contains atleast one key from the array permitted_list , with a not null value</p>
  <p>I used this code to check atleast one not null value exists in the dictionary</p>
  <pre><code>        //CHECK  atleast one not null value exists                     
          bool canProceed=dictionary.Any(e =&gt; !string.IsNullOrWhiteSpace(e.Value));                
  </code></pre>
  <p>Can we extend this to check for the existence of dictionary Key from the list of enums</p>
  <pre><code>       //Example in this case key Dog exists with a not null value So canProceed is TRUE                               
          //in this case#2 canProceed is FALSE , since the only permitted_list key is Cat and its value is NULL  
          var dictionaryf = new Dictionary&lt;string, string&gt;();
          dictionaryf.Add(&quot;cat&quot;,null);            
          dictionaryf.Add(&quot;Tiger&quot;, &quot;s&quot;); 
          dictionaryf.Add(&quot;Lion&quot;, &quot;exit sjs&quot;); 
  </code></pre>