I am having a problem in C#, the output states:
Error 1 Static class 'WindowsFormsApplication1.Hello2'
cannot derive from type 'System.Windows.Forms.Form'. Static classes
must derive from object.
How could I correct this?
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");
}
}
It means that
staticclasses can’t have: BaseClassin the declaration. They can’t inherit from anything. (The inheritance fromSystem.Objectis implicit by declaring nothing.)A
staticclass can only havestaticmembers. Only instance members are inherited, so inheritance is useless forstaticclasses. All you have to do is remove: Form.