我有以下代码:
Imports System.Collections.ObjectModel
Public Class clsCellListExtender
Public Class List(Of T)
Inherits Collection(Of T)
Private _iID As Integer = 0
Protected Overrides Sub InsertItem(index As Integer, item As T)
'your checks here
If TypeOf (item) Is clsCell Then
_iID += 1
Dim nCell As clsCell = DirectCast(item, clsCell)
nCell.TempID = _iID
End If
MyBase.InsertItem(index, item)
End Sub
End Class
End Class
当我尝试编译它时,编译器告诉我该行中的“T 无法转换为 clsCell”
Dim nCell As clsCell = DirectCast(item, clsCell)
有人可以告诉我我做错了什么吗?
谢谢!