A question for the C# gurus out there.
What is the difference, if there is one, between a destructor and a Finalize method in a class?
I recently discovered that Visual Studio 2008 considers a destructor synonymous with a Finalize method, meaning that Visual Studio won't let you simultaneously define both methods in a class.
For example, the following code fragment:
class TestFinalize
{
~TestFinalize()
{
Finalize();
}
public bool Finalize()
{
return true;
}
}
gives the following error on the call to Finalize in the destructor:
The call is ambiguous between the following methods or properties:
'TestFinalize.~TestFinalize()' and 'TestFinalize.Finalize()'
and if the call to Finalize is commented out, it gives the following error:
Type 'ManagementConcepts.Service.TestFinalize' already defines a member called
'Finalize' with the same parameter types