我有一个基类Base
和一个Child
继承自这个基类的类。基类是IDisposable
.
我调用Dispose
了类的方法Child
。有没有办法导航到覆盖的实现Child
?
Dim oChild as Child
oChild.Dispose()
当我在选择方法的同时按 F12 时Dispose()
,我最终Base.Dispose()
变成了Child.Dispose()
. 请注意,声明是作为Child
类型。
PS:我确实有 ReSharper,所以如果有人想用 ReSharper 找到一个简单的解决方案,那也可以。
编辑(代码示例):
Public Class CBase
Implements IDisposable
Private disposedValue As Boolean ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' Disposing etc.
End If
End If
Me.disposedValue = True
End Sub
Public Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
End Class
Public Class CChild
Inherits CBase
Protected Overrides Sub Dispose(disposing As Boolean)
Try
If disposing Then
' Dispose child specific
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
End Class
Public Class CExample
Public Sub ProvideExample()
Dim oChild As New CChild
oChild.Dispose() ' F12 on this leads me to CBase.Dispose
End Sub
End Class