title: Removing item from Dictionary in VB.net
body: <p>I have something like this:</p>
  
  <pre><code>    Public Shared Property PinnedChannelConnectionIds() As Dictionary(Of Integer, List(Of String))
      Get
          If _pinnedChannelConnectionIds Is Nothing Then
              Return New Dictionary(Of Integer, List(Of String))
          Else
              Return _pinnedChannelConnectionIds
          End If
      End Get
      Set(value As Dictionary(Of Integer, List(Of String)))
          _pinnedChannelConnectionIds = value
      End Set
  End Property
  </code></pre>
  
  <p>And then, have some data in dictionary as :</p>
  
  <p>1, {"c1","c2", "c3"} <br>
  2, {"c2","c4", "c6"} <br>
  3, {"c3","c5", "c1"} <br>
  4, {"c4","c3", "c6"}</p>
  
  <p>So to remove a specific item. Let say "c2" from the above dictionary.
  I am doing like this:</p>
  
  <pre><code>For Each channelKeyValuePair As KeyValuePair(Of Integer, List(Of String)) In Channel.PinnedChannelConnectionIds
              For Each item As String In channelKeyValuePair.Value.ToList()
                  If (item.Equals("c2")) Then
                      Channel.PinnedChannelConnectionIds(channelKeyValuePair.Key).Remove(item)
                  End If
              Next
          Next
  </code></pre>
  
  <p>But it throws error : <strong>Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.</strong></p>
  
  <p>Can anyone please help me out.
  Thanks in advance!! </p>