我在.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) –