Home » C# Basics » 03 - C# Programming - Part 1
3

Structure of a C sharp program

Explains the structure and guides how a basic C# program is wriiten and executed

Let us begin with a look at the structure of a basic C# program -

Open the Visual C# 2005 IDE. In the `Recent Projects' section of the start page, click on the link Create: Project...

This will display the New Project dialog box. Select Console Application from the Templates section.Provide a name for the project. Click `OK' to continue.

The IDE will display a tab with some code in it. This is our program file. The code for our application goes here. The IDE has already provided us with a basic structure:

Now we will add our own code to this structure. After the following line,

static void Main(string[] args)

Add this line of code inside the curly braces:

Console.WriteLine("Hello. Looks like my first application");

Note that when we are typing the code, the IntelliSense will display the available options for us.

The complete code on the page should look like this:

using System; using System.Collections.Generic; using System.Text;
namespace MyFirstApp { class Program { static void Main(string[] args) { Console.WriteLine("Hello. Looks like my first application"); } } }

Now we will run the code. Press `Ctrl+F5' keys. A console window will appear displaying the following output:

Hello. Looks like my first application

To close this window, press any key from the keyboard.