I can\'t believe I\'m still confused about this but, any way, lets finally nail it:
I have a class that overrides OnPaint to do some drawing. To speed things up, I c
You really need to look up the documentation for the brushes, pens etc.
If they aren't using unmanaged resources, you may not have to call Dispose. But the using/Dispose pattern is sometimes "misused". As an example, consider the ASP.NET MVC framework. Here you can write something like:
using(Html.BeginForm(...)){
///HTML input fields etc.
}
When Html.BeginForm(...)
is called, a FORM
tag will be output. When the using-statement ends, Dispose
will be called on the object returned from Html.BeginForm(...)
. Calling Dispose
causes the end FORM
tag to be rendered. In this way the compiler will actually enforce the pairing of FORM tags, so you won't forget the closing tag.