Program Entry point in C#

Example 3 & 4

kamran.cs
class zzz
{
  public static void Main(int i)
  {
  }
}


Compiler Warning
kamran.cs(3,21): warning CS0028: 'zzz.Main(int)' has the wrong signature to be an entry point

Compiler Error
error CS5001: Program 'kamran.exe' does not have an entry point defined

Here, the compiler first displays a warning that Main has not been created with the right parameters. The error, following the warning, proclaims that we have forgotten to create a function called Main. The signature includes the return type only in special cases as entry point.

kamran.cs
class zzz
{
  public static long Main()
  {
    return 0;
  }
}

Compiler Warning
kamran.cs(3,20): warning CS0028: 'zzz.Main()' has the wrong signature to be an entry point

Compiler Error
error CS5001: Program 'kamran.exe' does not have an entry point defined

The signature refers to the parameters given to the function plus the return value. Main in the above program returns 'long', hence we see the error.

You might also like...

Comments

About the author

Kamran Shakil Pakistan

I am 22 male. BS(Computer Science), MCSE, Brainbench certifed. Member of .NET Open source, Mono Project. E-author on various websites, including www.dotnetextreme.com, www.csharphelp.com and so...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Never trust a programmer in a suit.” - Anonymous