Dispose Pattern -- why void Dispose() is nonvirtual?

Dispose Pattern -- why void Dispose() is nonvirtual?

am 24.01.2008 20:19:45 von Gz

Hi,

Does anyone know the reason?

Thanks,
gz

Re: Dispose Pattern -- why void Dispose() is nonvirtual?

am 24.01.2008 20:28:31 von skeet

gz wrote:
> Does anyone know the reason?

Once you've got a virtual Dispose(bool) method, there's no need for the
normal Dispose to remain virtual, and keeping it so could lead to
inappropriate implementations which didn't call base.Dispose() - or
which called Dispose(bool) themselves as well as base.Dispose().

--
Jon Skeet -
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: Dispose Pattern -- why void Dispose() is nonvirtual?

am 24.01.2008 21:18:33 von Gz

On Jan 24, 1:28=A0pm, Jon Skeet [C# MVP] wrote:
> gz wrote:
> > Does anyone know the reason?
>
> Once you've got a virtual Dispose(bool) method, there's no need for the
> normal Dispose to remain virtual, and keeping it so could lead to
> inappropriate implementations which didn't call base.Dispose() - or
> which called Dispose(bool) themselves as well as base.Dispose().
>
> --
> Jon Skeet - http://www.pobox.com/~skeet=A0 Blog:http://ww=
w.msmvps.com/jon.skeet
> World class .NET training in the UK:http://iterativetraining.co.uk

I see. Thanks.