|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Destructor Syntax in C# and C++
You cannot call or override the Object.Finalize method from the C# or C++ programming languages. C# uses destructors as the mechanism for writing finalization code, as described in .
In C++, destructor syntax is used to implement the Dispose method. C++ provides its own syntax for implementing the Finalize method, as described in.
Prior to version 2.0 of the .NET Framework, C++ used destructor syntax to implement the Finalize method, as C# does, and did not have special syntax for implementing the Dispose method. To compile C++ code that uses the earlier syntax, use the /clr:oldSyntax compiler option.
Although they look similar, the C# and C++ destructors do not have the same semantics as unmanaged C++ destructors. Managed code does not support anything similar to C++ destructor semantics.