A console application is a program that you can execute at the Command prompt. Its also known as CUI, Console User Interface, by some.
Let us go ahead and create such a console app. Let us call it OFCA.(Our First Console App). We shall code in C# and use the Command line compiler options, to compile our app.
Coding the application,
using System;
class OFCA
{
static void Main()
{
Console.WriteLine("C# Welcomes you...");
}
}
This i enter into Notepad, save as OFCA.cs.
".cs" is the file extension for a C# source-code file.
Just to illustrate,
Note that i am not using Visual Studio IDE to create my console app, nor any other such visual tools to create my source code.
The important thing to observe here is, we can build our C# applications even without such development environments. Also, You can use any text editor to write C# code, not just notepad.
Next, i navigate to the folder that has my source code at the Visual Studio command prompt and execute this command.
csc OFCA.cs
I observe that the compiler compiles my source code and outputs an Executable file with a .EXE extension.
I go ahead and execute this program at the command prompt.

The program executed and printed C# welcomes you at the command prompt.
Note that i have not provided any command line switches for the C# compiler.
No comments:
Post a Comment