我在.NET框架中看到过一些情况,当您实现一个接口时,Visual Studio会生成注释(以及其他好的东西,如区域)。向接口添加注释
一个很好的例子是IDisposable
。当你实现它时,Visual Studio生成以下代码块:
#Region "IDisposable Support"
Private disposedValue As Boolean ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).
End If
' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' TODO: override Finalize() only if Dispose(ByVal disposing As Boolean) above has code to free unmanaged resources.
'Protected Overrides Sub Finalize()
' ' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
' Dispose(False)
' MyBase.Finalize()
'End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
这是我能在自己的代码中做的事吗?如果是这样,怎么样?我想在接口的方法中添加一些注释,告诉实现者该方法的一般用途是什么。
[VB.net:Custom'TODO:List on a Interface]的可能重复(http://stackoverflow.com/questions/2884036/vb-net-custom-todo-list-on-an-interface) –