Interface IMyInterface
Function MyFunc() As Integer
End Interface
Class InterClass
Implements IMyInterface
Public Function MyFunc() As Integer Implements IMyInterface.MyFunc
Return MsgBox("巴西世界杯")
End Function
End Class
Public Class Class1
Sub MySub()
Dim Inter1 As IMyInterface = New interclass
Dim Finc1 As New Func(Of String, String)(AddressOf Inter1.MyFunc)
'声明委托Func1过程中也采用了接口,这样用法最合理吗?
' 如果,不用接口直接委托调用函数有什么区别?
Dim Cla1 As New InterClass
Dim Finc2 As New Func(Of String, String)(AddressOf Cla1.MyFunc)
End Sub
End Class
------解决方案--------------------
没有什么区别,也不存在哪个更合理的问题,代码符合实际需求的就是好代码