我有以下界面和类
Public Interface IMyInterface
Sub GenericImplementation()
End Interface
Public Class MyClass
Implements IMyInterface
Public Sub GenericImplementation() implements IMyInterface.GenericImplementation
'doing some stuff
end Sub
Public Sub DoRefresh()
'doing some stuff
End Sub
End Class
现在我有一些代码,我想检查我的对象是否作为接口传递是具体类型MyClass
,然后执行DoRefresh()
Public Sub TestMethod(testObject As IMyInterface)
Dim test = TryCast(testObject, MyClass)
If test IsNot Nothing Then
test.DoRefresh()
End If
End Sub
当我调试代码时,我可以清楚地看到我的界面实例是'MyClass'。但是当我尝试尝试时,它什么也没有返回。