Basic Dot Net Question: Download Questions PDF
I am constantly writing the drawing procedures with System.Drawing.Graphics, but having to use the try and dispose blocks is too time-consuming with Graphics objects. Can I automate this?
Answer:
Yes, the code
System.Drawing.Graphics canvas = new System.Drawing.Graphics();
try
{
//some code
}
finally
canvas.Dispose();
is functionally equivalent to
using (System.Drawing.Graphics canvas = new System.Drawing.Graphics())
{
//some code
} //canvas.Dispose() gets called automatically
System.Drawing.Graphics canvas = new System.Drawing.Graphics();
try
{
//some code
}
finally
canvas.Dispose();
is functionally equivalent to
using (System.Drawing.Graphics canvas = new System.Drawing.Graphics())
{
//some code
} //canvas.Dispose() gets called automatically
Download Dot Net Interview Questions And Answers
PDF
Previous Question | Next Question |
Differences between Datagrid, Datalist and Repeater in .NET? | How do you trigger the Paint event in System.Drawing? |