When do I need to implement a finalizer or IDisposable?
Recently another developer was experimenting with structs we are using to serialize a class for eventual mapping into an XmlDocument to transmit to a vendor. I noticed he had derived from IDisposable but had not implemented any Dispose pattern for the struct. I queried him on it, "What is the rationale for implementing IDisposable on a struct (a value type)?" (I just love to challenge other developers, even when I haven't a clue what the hell I'm talking about). Fact of the matter is, this is one of the most esoteric areas of working with the .NET Framework, and if you search around, you will find a lot of people simply parroting what they have seen elsewhere, which of course leads you on a wild goose chase to nowhere pretty fast. The Nitty-Gritty: Finalizers only need to be implemented when you hold onto resources that need cleaning up. Example: FileStream holds onto a native file handle and implements a finalizer to release the handle when the FileStream is garba...