C# Question: How do I declare a body?

Status
Not open for further replies.

Crocodyle

Solid State Member
Messages
18
Well I recently began with Visual C# and thought "Wow, this is pretty interesting."
So then I started googling and learned that "Close()" closes the window and MessageBox.Show("Message of Pop up", "Title of Pop up"); ACTUALLY DOES WHATEVER YOU JUST READ.

So yeah, I'm pretty excited about this.

Three things that I can't fix though I've googled it alot are these errors:
Error 1:'UserInterface.Form1.button3_Click(object, System.EventArgs)' must declare a body because it is not marked abstract, extern, or partial
In order of the columns the info is "Form1.cs" - Line 45 - Column 22
Error 2:Program 'C:UsersAdministratorDocumentsVisual Studio 2008ProjectsUserInterfaceUserInterfaceobjDebugUserInterface.exe' has more than one entry point defined: 'UserInterface.Program.Main()'. Compile with /main to specify the type that contains the entry point.
In order of the columns the info is "Program.cs" - Line 14 - Column 21
Error 3:Program 'C:UsersCody SantosDocumentsVisual Studio 2008ProjectsUserInterfaceUserInterfaceobjDebugUserInterface.exe' has more than one entry point defined: 'UserInterface.Form1.ProcessStart.Main(string[])'. Compile with /main to specify the type that contains the entry point.
In order of the columns the info is "Form1.cs" - Line 48 - Column 25

And just for the sake of helping you guys out, below is the actual coding of my project.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UserInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Thank you.", "Ok");
Close();
}

private void button1_Click(object sender, EventArgs e)
{
Close();
}

private void label1_Click(object sender, EventArgs e)
{

}

private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void button3_Click(object sender, EventArgs e);
class ProcessStart
{
static void Main(string[] args)
{
Process notePad = new Process();

notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";

notePad.Start();
}
}
}
}

As you guys can see, I want to try launching different applications through this little application/program that I am trying to do.
All tips will be greatly appreciated.
 
In future, please put your code in [ code] tags not [ quote] tags otherwise it is difficult to read.
Error 1 says that you have not implemented the button3_Click method. Change
Code:
private void button3_Click(object sender, EventArgs e);
to
Code:
private void button3_Click(object sender, EventArgs e){}
Error 2 and 3 are because you have two main methods and the compiler needs to know which one you want to use as the entry point to the application.
The other main method is probably in the other part of your partial class Form1 and if you want it to start in the main that you have written then there is probably an option in your IDE to prevent that method being generated.
 
Status
Not open for further replies.
Back
Top Bottom