I
Israel
I always wondered why the using command can only take one object. I
always find that this isn't sufficient for drawing so I end up always
disposing in my finally block but then I have to remember to put
everything in there.
Why can't the using command just allow something like this?
using (Pen mypen = new Pen(Color.Black), Brush mybrush = new
SolidBrush(Color.Blue))
{
}
I thought about creating some object that takes an array of
IDisposable objects in its constructor and then calls their dispose
methods from its dispose method but that would be a very clunky
interface to deal with. I would much rather just use a try...finally
pattern.
always find that this isn't sufficient for drawing so I end up always
disposing in my finally block but then I have to remember to put
everything in there.
Why can't the using command just allow something like this?
using (Pen mypen = new Pen(Color.Black), Brush mybrush = new
SolidBrush(Color.Blue))
{
}
I thought about creating some object that takes an array of
IDisposable objects in its constructor and then calls their dispose
methods from its dispose method but that would be a very clunky
interface to deal with. I would much rather just use a try...finally
pattern.