Today I've caught curious exception in the code like below:
Just an "optimization" not to create a pen every time and keep it static for "caching".
class Drawer
{
private static readonly Pen = new Pen(Color.White) { Width = 5 };
public Bitmap DrawEllipse(int width, int height)
{
var bitmap = new Bitmap(width, height);
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.DrawEllipse(Pen, 0,0, width, height);
}
return bitmap;
}
}
Just an "optimization" not to create a pen every time and keep it static for "caching".