Archive for the ‘B- First C# program’ Category

Your first C# program

Sunday, March 8th, 2009

To start, open your MSVS express (Free) or Pro

Go to File -> New -> Project

Chose Console Application from the icons that appear

Name your project HelloWorld

—-

You will see MSVS creating a new file for you named “Program.cs”, and in that file you should see something like.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}

Already we have a namespace (Same as project name), a Program Class,
and a program entry point that is always named Main.

So, Add the following line to your Main (Between the currly brackets)

Console.WriteLine(“HelloWorld”);
Console.ReadLine();

Now go to the build menu, and then to Build Solution

Now navigate to your Documents directory, In my case on Windows Vista it is
C:\Users\yazeed\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\bin\Debug

and double click HelloWorld.exe

bravo, you are done with your first C# program….