G
Guest
I have been asked to change an existing program which Implemented a
Collection Class
The current class had what is below (its just a summary of the code)
Public Class FieldList
Implements System.Collections.IEnumerable
Private thisColl As Collection
Private Sub New()
thisColl = New Collection
End Sub
Public Function GetEnumerator() As System.Collections.IEnumerator
Implements System.Collections.IEnumerable.GetEnumerator
GetEnumerator = thisColl.GetEnumerator
End Function
....
End Class
I wanted to use a SortedList instead of a Collection so changed it such:
Private thisColl As SortedList
Private Sub New()
thisColl = New SortedList
End Sub
After making a couple more changes to where we were adding elements, it
compiled, but when I use a for each statement, I get an error, after the
GetEnumerator is called.
"Specified cast is not allowed"
Any help would be appreciated.
Collection Class
The current class had what is below (its just a summary of the code)
Public Class FieldList
Implements System.Collections.IEnumerable
Private thisColl As Collection
Private Sub New()
thisColl = New Collection
End Sub
Public Function GetEnumerator() As System.Collections.IEnumerator
Implements System.Collections.IEnumerable.GetEnumerator
GetEnumerator = thisColl.GetEnumerator
End Function
....
End Class
I wanted to use a SortedList instead of a Collection so changed it such:
Private thisColl As SortedList
Private Sub New()
thisColl = New SortedList
End Sub
After making a couple more changes to where we were adding elements, it
compiled, but when I use a for each statement, I get an error, after the
GetEnumerator is called.
"Specified cast is not allowed"
Any help would be appreciated.