 code example illustrating the design pattern for implementing Finalize and Dispose, see Implementing a Dispose Method.
Occasionally a domain-specific name is more appropriate than Dispose. For example, a file encapsulation might want to use the method name Close. In this case, implement Dispose privately and create a public Close method that calls Dispose. The following code example illustrates this pattern. You can replace Close with a method name appropriate to your domain. This example requires the System namespace.
The following rules outline the usage guidelines for the Finalize method:
Implement Finalize only on objects that require finalization. There are performance costs associated with Finalize methods.
If you require a Finalize method, the object has held onto. The Finalize method should not reference any other objects.
Do not directly call a Finalize method on an object other than the object's base class. This is not a valid operation in the C# programming language.
Call the base class's Finalize method from an object's Finalize method..