EDIT: To eager editors, please read the FULL question In addition, since this question is not only about disposing
.
So far I've seen this:
protected override Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
c.Dispose()
}
and this:
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);
}
And Microsoft says CA2215: Dispose methods should call base class dispose
, here. In addition, since this question is not only about disposing, here is another example from Microsoft calling base
at the last line.
Which one is the correct/most common/better if any?