Main

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a C# teacher and he gave me some 'homework' to do whilst he was on
holiday. it says: insert this code into the main section. but what is the
Main
Section? I'd rather know now because he gets really angry if you dont do
your homework.

thanks
 
Alvo,
"Main" referes to the main entry point of your program.

static void Main()
{
// Place code here.
}

Jason Newell, MCAD
Software Engineer
 
Alvo von Cossel I said:
I have a C# teacher and he gave me some 'homework' to do whilst he was on
holiday. it says: insert this code into the main section. but what is the
Main
Section? I'd rather know now because he gets really angry if you dont do
your homework.

I suspect he means the Main method, like:

static void Main()
{
// Do stuff here
}

The Main method is the entry point to a .NET application.
 
"The Main method is the entry point of your program, where the program
control starts and ends. It is declared inside a class or struct. It must be
static. It can either have a void or int return type. The Main method is
where you create objects and invoke other methods. The Main method can be
declared without parameters or with parameters. The latter form allows your
program to read command-line arguments."

C# Programmer's Reference
 
Back
Top