编辑:对于热心的编辑,请阅读完整问题In addition, since this question is not only about disposing
。
到目前为止,我已经看到了这个:
protected override Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
c.Dispose()
}
这:_
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
// Dispose managed resources.
}
// There are no unmanaged resources to release, but
// if we add them, they need to be released here.
}
disposed = true;
// If it is available, make the call to the
// base class's Dispose(Boolean) method
base.Dispose(disposing);
}
微软说CA2215: Dispose methods should call base class dispose
,在这里。另外,由于这个问题不仅仅是关于配置的,这里是微软base
在最后一行调用的另一个例子。
如果有的话,哪一个是正确的/最常见的/更好的?