I have a SortedDictionary and I am using Linq to try and find the int32 key I want to delete, when I know the value. I know this sounds a bit backward, but...
Anyway, once I discover the int32 key, if it still is in the SortedDictionary, i want to remove that entry. However, once I do that, I get my exception...
Once it hits this line, game over! I get an InvalidOperationException occurred (Collection was modified after the enumerator was instantiated.)
Full code for the entire sub is attached...
What am I doing wrong? What do I need to do to fix it? Syntax help requested please!!!
Thanks in advance!
Dim BlendLineETList As New SortedDictionary(Of Int32, String)
Private Sub DeleteElapsedTimeOfAParticularCar(ByVal CarKey As String)
If BlendLineETList.ContainsValue(CarKey) Then
Dim KeyResult = From SDValues In BlendLineETList Where SDValues.Value = CarKey _
Dim ETToDelete As Int32 = 0
For Each SDValue In KeyResult
Dim ElapsedTimeToDelete = SDValue.Key
If BlendLineETList.ContainsKey(ElapsedTimeToDelete) Then