title: Check if ALL items in Array exist in Dictionary
body: <p>I have some legacy code which consists of:</p>
  
  <p>A <code>Dictionary</code> (<code>dictParts</code>) populated during startup with approx. 350,000 items (does not change during runtime).
  <code>dictParts</code> is a <code>System.Collections.Generic.Dictionary(Of String, System.Data.DataRow)</code>.</p>
  
  <p>Each item in <code>dictParts</code> is a <code>System.Collections.Generic.KeyValuePair(Of String, System.Data.DataRow)</code>.</p>
  
  <p>An <code>Array</code> (<code>arrOut</code>) which frequently has items added and removed (typically between 2-6 items in the array).
  <code>arrOut</code> is a <code>System.Array</code> containing only <code>string</code>s.</p>
  
  <p>Each time the array changes I need to see if:</p>
  
  <ul>
  <li>All the items in the array exist in the index</li>
  <li>Some of the items in the array exist in the index</li>
  </ul>
  
  <p>I imagine that looping through the index 350,000 every time the array changes is going to have massive performance hit and looked to LINQ to help.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>Private Sub btnTest_Click(sender As System.Object, e As System.EventArgs) Handles btnTest.Click
  
      Dim dictParts = New Dictionary(Of Integer, String) _
                      From {{1, "AA-10-100"}, _
                            {2, "BB-20-100"}, _
                            {3, "CC-30-100"}, _
                            {4, "DD-40-100"}, _
                            {5, "EE-50-100"}}
  
  
      Dim arrOut() As String = {"AA-10-100", "BB-20-100", "CC-30-100"}
  
      'Tried
      Dim allPartsExist As IEnumerable(Of String) = arrOut.ToString.All(dictParts)
      'And this
      Dim allOfArrayInIndex As Object = arrOut.ToString.Intersect(dictParts).Count() = arrOut.ToString.Count
  
  End Sub
  </code></pre>
  
  <p>I keep getting errors: Unable to cast object of type 'System.Collections.Generic.Dictionary<code>2[System.Int32,System.String]' to type 'System.Collections.Generic.IEnumerable</code>1[System.Char]'.</p>
  
  <p>Please could someone advise where I am going wrong.</p>