Boneyards
Boneyards

Reputation: 83

Initialize Component Error C#

So I was all done with my program and tried to edit a few small things at the top, and started getting errors and can't change them back. Here is the code:

namespace FinalProject
{
    public partial class Form : Form
    {
        public Form();
        {
           InitializeComponent();

        }
    }
}

I changed the Form: Form part and then it made the InitializeComponent(); into an error. Tried to change it back and its still showing the error. Undo is not an option and I'm sure it's an easy fix.

Upvotes: 1

Views: 4979

Answers (2)

Peter Stock
Peter Stock

Reputation: 311

A Class named Form cannot inherit another class also named Form. You have to give it a different name.

Upvotes: 4

Amiram Korach
Amiram Korach

Reputation: 13286

  1. Remove the semicolon at the end of the first line of the constructor.
  2. Change your class name to something other than "Form".

Upvotes: 10

Related Questions