I have created a dictionary base collection
Public Class SBTSessions
Inherits System.Collections.DictionaryBase
Public Sub Add(ByVal Session As SBTSession, ByVal Key As String)
Dictionary.Add(Key, Session)
End Sub
Default Public ReadOnly Property Item(ByVal Key As String) As SBTSession
Get
Return CType(Dictionary.Item(Key), SBTSession)
End Get
End Property
End Class
In my app I have created and populated an SBTSessions collection
then I declared a variable Session as SBTSession
and try to iterate through the collection with
For Each Session In MyCollection
and I get a runtime error that I'm attempting an invalid cast
What have I got wrong
BTW I have used an IEnumerator to loop through the collection but I'm anal and know I should be able to use For Each
For Each Session
JHall
Public Class SBTSessions
Inherits System.Collections.DictionaryBase
Public Sub Add(ByVal Session As SBTSession, ByVal Key As String)
Dictionary.Add(Key, Session)
End Sub
Default Public ReadOnly Property Item(ByVal Key As String) As SBTSession
Get
Return CType(Dictionary.Item(Key), SBTSession)
End Get
End Property
End Class
In my app I have created and populated an SBTSessions collection
then I declared a variable Session as SBTSession
and try to iterate through the collection with
For Each Session In MyCollection
and I get a runtime error that I'm attempting an invalid cast
What have I got wrong
BTW I have used an IEnumerator to loop through the collection but I'm anal and know I should be able to use For Each
For Each Session
JHall