我在 C# 中遇到问题,输出状态为:
Error 1 Static class 'WindowsFormsApplication1.Hello2'
cannot derive from type 'System.Windows.Forms.Form'. Static classes
must derive from object.
我该如何纠正这个问题?
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Hello2.calculate();
}
}
public class Hello : Form
{
public string test { get; set; }
}
public static class Hello2 : Form
{
public static void calculate()
{
Process.Start("test.exe");
}
}
代表着static
类不能有: BaseClass
在声明中。他们不能继承任何东西。 (继承自System.Object
通过不声明任何内容来隐含。)
A static
类只能有static
成员。只有实例成员被继承,所以继承对于static
类。您所要做的就是删除: Form
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)