i review my code with codacy and codacy says following to me
Remove the 'button1' field and declare it as a local variable in the relevant methods. The line that codacy mean is private Button button1;
The method in this case button1_Click
my code is (only a little example because my code is much bigger):
namespace WindowsFormsApp1 { public class Form1 : Form { private Button button1; public Form1() { InitializeComponent(); } #region Vom Windows Form-Designer generierter Code private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(349, 155); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion private void button1_Click(object sender, EventArgs e) { } } } I dont know how to do that, can anyone explain me what to do here? Greetings
