I have the following class:
public class MailData : IDisposable
{
public IDictionary<String, Tuple<Byte[], String>> Attachments { get; set; }
public String From { get; set; }
public IList<String> To { get; set; }
public MailType Type { get; set; }
} // MailData
What would be the correct way to dispose the class?
I mean, I think I should remove all Byte[] from Dictionary ...
What about the other properties?
.NET is a managed environment and you have to allow the Garbage Collector to do it's job, there is no reason for you to dispose simple reference classes and byte[] is still a reference.
Usually you use the Dispose pattern to let go of valuable resources such as file I/O, various Streams, database connections...etc
In your case however, there is no need to do anything on your own.
Welcome to the managed world of C#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With