17 December, 2009

First C# Console application

Starting with the basic program i.e displaying a message using console application.
The below mentioned program has
1) namespace : e.g. using System;
2) a class : e.g. Class Consoledemo{… }
3) a Main method : e.g. static void Main() {….}
4) statement : e.g. console.writeline(“This is my first article for my site”);

How a complete program in c# look:
// Namespace Declaration
using System;

// Program start class
class Consoledemo
{
// Main begins program execution.
static void Main()
{
// Write to console
Console.WriteLine("This is my first article for my site");
}
}


How to compile a c# code through command line:

CSC.exe Consoledemo.cs

1 comment: