
What
is the purpose of main() function
|
When you
execute the above program, you will end up in the following error:
Program Application1.exe' does not contain a static 'Main' method
suitable for an entry point
This is because the above program does not include Main function. To make it work, include the following Main function inside sampleClass:
public static
void Main() {
sampleMethod();
}
Now when
you execute the program, you will get the following output:
Executing sampleMethod..
The Main function can take four different forms. They are mentioned below:
static void
Main() { }
static void Main(string[ ]args) { }
static int Main() { }
static int Main(string[ ] args) { }
But remember
that your program can have only one Main function which can have any of
the above shown signatures. If multiple Main functions are defined, then
you will get this error:
Program Application1.exe' has more than one entry point defined:
'Application1.sampleClass.Main()'
_______________________________________________________________________
FREE Subscription
Subscribe
to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
Note
: We never rent, trade, or sell my email lists to
anyone.
We assure that your privacy is respected
and protected.
Visit .NET Programming Tutorial Homepage
______________________________________________________