Console Application
Console application are
command line oriented applications that allow user to
read characters from the console, and
write characters to the console.
Console applications are typically designed
without graphical user interface and are compiled in a stand-alone executable file.
Since information can be written to and read from the console window, this makes the console application a great way to learn new programming techniques without having to be concerned with the user interface.
Entry point method - Main
- The Main method is the entry point of a C# application. When the application is started, the Main method is the first method that is invoked; it is where the program control starts and ends.
- Main is declared inside a class or struct. Main must be static and it need not be public.
- Main can either have a void or int return type.
Command Line Arguments
It is possible to pass some values from the command line to your programs when they are executed. These values are called command line arguments. Command line arguments are important for your program especially when you want to control program from outside instead of hard coding those values inside the code.
The string
args variable contains all the values passed from the command line.
The Main method can be declared with or without a string[] parameter that contains command-line arguments. When using Visual Studio to create Windows applications, you can add the parameter manually or else use the Environment class to obtain the command-line arguments.