M
Martijn Mulder
When I want to invoke Dispose() automatically on an object, I can use
using(object)
{
//do something with object
}
and after the closing brace the object is Disposed(). But what get
disposed when I use code like this
override protected void OnPaint(PaintEventArgs e)
{
using(e.Graphics.Clip=GetMyCustomRegion())
{
e.Graphics.DrawImage(bitmap,0,0);
}
}
Is the Region object returned by GetMyCustomRegion() succesfully
Disposed()? How does it influence the Clip-property of the Graphics object?
Also, can I nest 'using' statement like this:
override protected void OnPaint(PaintEventArgs e)
{
using(e.Graphics.Clip=GetMyCustomRegion())
using(Bitmap bitmap=new Bitmap(34,55))
{
e.Graphics.DrawImage(bitmap,0,0);
}
}
Do both the implicit Region object and the Bitmap object get Disposed()?
using(object)
{
//do something with object
}
and after the closing brace the object is Disposed(). But what get
disposed when I use code like this
override protected void OnPaint(PaintEventArgs e)
{
using(e.Graphics.Clip=GetMyCustomRegion())
{
e.Graphics.DrawImage(bitmap,0,0);
}
}
Is the Region object returned by GetMyCustomRegion() succesfully
Disposed()? How does it influence the Clip-property of the Graphics object?
Also, can I nest 'using' statement like this:
override protected void OnPaint(PaintEventArgs e)
{
using(e.Graphics.Clip=GetMyCustomRegion())
using(Bitmap bitmap=new Bitmap(34,55))
{
e.Graphics.DrawImage(bitmap,0,0);
}
}
Do both the implicit Region object and the Bitmap object get Disposed()?