我有一个像这样的通用类构建
Public Class TabellaCustom(Of myType, TValue) Implements IEnumerable(Of TValue)
Private mKey As myType
Private mContenuto As TValue
...
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of TValue) Implements System.Collections.Generic.IEnumerable(Of TValue).GetEnumerator
Return DirectCast(mContenuto, IEnumerator(Of TValue))
End Function
当我做这样的事情时
dim Color as new ColorsEnumerable
Dim test(0) As StampeCommonFunctions.TabellaCustom(Of Color, String)
test(0) = New StampeCommonFunctions.TabellaCustom(Of Color, String)(Color.Red, "Red")
test.GetEnumerator()
我收到一个错误:
Unable to cast object of type 'System.String' to type 'System.Collections.Generic.IEnumerator`1[System.String]'.
我该如何解决这个错误?我必须在类中指定对象的类型?