what is the exact use of main() and explain it?
what is the exact use of main() and explain it?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted May 9, 2015, 6:11 AM
The Main method is the entry point of a C# console application or windows application. (Libraries and services do not require a Main method as an entry point.). When the application is started, the Main method is the first method that is invoked.
There can only be one entry point in a C# program.
The Main method is the entry point of an .exe program; it is where the program control starts and ends.
Main is declared inside a class or struct. Main must be static and it should not be public. (In the earlier example, it receives the default access of private.) The enclosing class or struct is not required to be static.
Main can either have a void or int return type.
The Main method can be declared with or without a string[] parameter that contains command-line arguments. When using Visual Studio to create Windows Forms applications, you can add the parameter manually or else use the Environment class to obtain the command-line arguments. Parameters are read as zero-indexed command-line arguments. Unlike C and C++, the name of the program is not treated as the first command-line argument.
Dipankar BiswasPosted May 9, 2015, 3:46 AM
check this link..http://www.dotnetperls.com/main
Manoj BhoirPosted May 9, 2015, 3:37 AM
Main() method used to signify the entry point of your application. This Main() method present in every executable C# application. C# executable means any Console application, Windows desktop application or Windows service application.
You will get details about Main method on internet. For more information check these links :
Main Method in C#
http://www.codeproject.com/Articles/479467/Main-Method-in-Csharp
Main () and Other Methods
https://msdn.microsoft.com/en-us/library/ms228506%28v=vs.90%29.aspx
Main() and Command-Line Arguments (C# Programming Guide)
https://msdn.microsoft.com/en-us/library/acy3edy3.aspx