Quick Interview Questions
What is the execution entry point for a C# console application ?
The Main method is the entry point of a C# console application or windows application. When the application is started, the Main method is the first method that is invoked. The Main() method must be static and it should not be public.
More about.....C# console based application
Can we create a console application in c# without Main() method ?
No you can't, All executables in .NET need an entry point.
Every C# application must contain a single Main method specifying where program execution is to begin.
Why Main() method is static ?
A static method can be called without instantiating an object. Therefore main() method needs to be static in order to allow it to be the entry to your program.
What is string args in Main method ?
The string args may contain any number of Command line arguments which we want to pass to Main() method. Parameters are read as zero-indexed command-line arguments. For example args will give you the first command line parameter, if there is one. The Main() method can be declared with or without a string argument 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.
What is the use of GetCommandLineArgs() method ?
GetCommandLineArgs() returns a string array containing the command-line arguments for the current process. The first element in the array contains the file name of the executing program. The remaining elements contain any additional tokens entered on the command line.