I need to use a BitmapImage in a using statement, how could this be done?
using (BitmapImage bitmap = new BitmapImage())
{
...
I am guessing the way to do it is by extending IDisposable but I have never done that before.
Thanks in advance
You can’t do it.
BitmapImageis sealed so you can’t derive from it. Furthermore, I don’t know why you would implementIDisposablein a .NET Framework class. The most you could do is a wrapper class which would contain yourBitmapImage, and implementIDisposable.Example: