[Mono-list] Help: Making class stubbs

Dan Lewis dihlewis@yahoo.co.uk
18 Apr 2002 17:47:52 +0100


On Thu, 2002-04-18 at 17:03, Daniel Carrera wrote:
> 1) I'm going through the documentation at MSDN and sone protected methods
> say "[C#] In C#, finalizers are expressed using destructor syntax".
> 
> What is the destructor syntax?

The destructor syntax is C# syntactic sugar for this pattern:

	protected override void Finalize ()
	{
		// finalize code
		base.Finalize ();
	}

Instead you use this syntax , which makes calling the base finalizer
implicit, and supposedly safer:

	~A ()
	{
		// finalize code
	}

They are rather expensive for the runtime to deal with, so you should
try to avoid them where possible. Also it's unfortunate that for some
reason the Microsoft docs always mark Finalize() as 'overridden',
whether it is or not.

A good thing to do is to click on the method for more details. If the
description is specific to the class then add a destructor. If it just
says ~Object() then don't. For instance, compare the documentation for
System.IO.FileStream with that of System.IO.Stream.

Dan.



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com