Mega Code Archive

 
Categories / C# Tutorial / 2D Graphics
 

Disposal Errors

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms;   class Form1 : Form   {     public Form1()     {       InitializeComponent();     }     private void Form1_Paint(object sender, PaintEventArgs e)     {       Pen p = Pens.Black;              p.Dispose();     }     private void InitializeComponent()     {       this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);       this.ClientSize = new System.Drawing.Size(292, 271);       this.Name = "Form1";       this.Text = "Form1";       this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);     }     [STAThread]     static void Main()     {       Application.EnableVisualStyles();       Application.Run(new Form1());     }   }