IDisposable Structures

Problem
You have a structure that implements the IDisposable interface. You’d like to know how to implement the Dispose method.

Solution
Implement this interface with a public Dispose method. Don’t use explicit interface implementation.

Comments
If you use explicit interface implementation, you force the C# compiler to box the structure if it’s used in a using block.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s