所以基本上,问题是我正在尝试制作一个“假”和拖钓程序,该程序考虑为我的朋友修复Visual Studio 2019(他为什么想要这个idk)。这是代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace VS_Error_Checker
{
public partial class Form2 : Form
{
private System.Windows.Forms.Timer x = new Timer();
public event EventHandler Tick;
public Form2()
{
InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
x.Tick += new EventHandler(TimerEventProcessor);
label1.Text = "Corrupted Files : 15";
x.Interval = 3000;
label1.Text = "Corrupted Files : 34";
x.Interval = 1500;
label1.Text = "Corrupted Files : 40";
x.Interval = 1500;
label2.Text = "Corrupted registry keys : 15";
x.Interval = 1500;
label2.Text = "Corrupted registry keys : 27";
x.Interval = 900;
label3.Text = "Non-downloaded files : 14";
}
private static void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
{
x.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);
}
}
}
请帮助,我真的需要帮助,因为我正在使用相同代码的其他一些项目:(
我忘了告诉你,导致实际错误的代码是
private static void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
{
x.Stop();
}
(错误:Error CS0120 An object reference is required for the property, method or non-static field 'Form2.x'